Browse Source

Trade, MeshTools: deprecate MeshDataXD and everything that uses it.

pull/371/head
Vladimír Vondruš 6 years ago
parent
commit
006790969a
  1. 4
      doc/changelog-old.dox
  2. 30
      doc/changelog.dox
  3. 17
      doc/snippets/MagnumTrade.cpp
  4. 4
      src/Magnum/GL/Mesh.h
  5. 17
      src/Magnum/MeshTools/Compile.cpp
  6. 36
      src/Magnum/MeshTools/Compile.h
  7. 40
      src/Magnum/MeshTools/Test/CompileGLTest.cpp
  8. 12
      src/Magnum/Trade/AbstractImporter.cpp
  9. 4
      src/Magnum/Trade/AbstractImporter.h
  10. 28
      src/Magnum/Trade/CMakeLists.txt
  11. 6
      src/Magnum/Trade/MeshData2D.cpp
  12. 18
      src/Magnum/Trade/MeshData2D.h
  13. 7
      src/Magnum/Trade/MeshData3D.cpp
  14. 18
      src/Magnum/Trade/MeshData3D.h
  15. 2
      src/Magnum/Trade/Test/AbstractImporterTest.cpp
  16. 14
      src/Magnum/Trade/Test/CMakeLists.txt
  17. 9
      src/Magnum/Trade/Test/MeshData2DTest.cpp
  18. 9
      src/Magnum/Trade/Test/MeshData3DTest.cpp
  19. 6
      src/Magnum/Trade/Trade.h

4
doc/changelog-old.dox

@ -510,8 +510,8 @@ No dependency changes in this release.
- New @ref Shaders::Generic class with common definitions, so you can
configure mesh for the generic shader and render it with any other
compatible shader
- Convenience @cpp hasNormals() @ce, @cpp hasTextureCoords2D() @ce functions to
@ref Trade::MeshData2D and @ref Trade::MeshData3D
- Convenience @cpp hasNormals() @ce, @cpp hasTextureCoords2D() @ce functions
in @cpp Trade::MeshData2D @ce and @cpp Trade::MeshData3D @ce
- OpenGL ES 3.0 build now shares list of vendor extensions with OpenGL ES 2.0
build (i.e. only those extensions that aren't part of ES 3.0 are present in
@cpp Extensions @ce)

30
doc/changelog.dox

@ -379,6 +379,8 @@ See also:
@ref GL::DynamicAttribute::DataType::Half and @ref GL::PixelType::Half that
are consistent with the @ref Half type used elsewhere.
- @cpp Trade::AbstractImporter::mesh2D() @ce,
@cpp Trade::MeshData2D @ce, @cpp Trade::MeshData3D @ce,
@cpp Trade::AbstractImporter::mesh2D() @ce,
@cpp Trade::AbstractImporter::mesh3D() @ce and related APIs are
deprecated in favor of @ref Trade::AbstractImporter::mesh() and the new
@ref Trade::MeshData API. For backwards compatibility, importers
@ -721,8 +723,8 @@ Released 2019-10-24, tagged as
location
- @ref MeshTools::generateSmoothNormals() for generating weighted smooth
normals of indexed meshes (see [mosra/magnum#229](https://github.com/mosra/magnum/pull/229))
- @ref MeshTools::compile(const Trade::MeshData3D&, CompileFlags) now accepts
optional flags to control normal generation
- @cpp MeshTools::compile(const Trade::MeshData3D&, CompileFlags) @ce now
accepts optional flags to control normal generation
@subsubsection changelog-2019-10-new-platform Platform libraries
@ -1108,7 +1110,7 @@ Released 2019-10-24, tagged as
- Reading of float textures on ES3 contexts using
@ref DebugTools::textureSubImage() returned a zero-sized image by accident
- @ref MeshTools::compile() was producing an incorrect mesh when
@ref Trade::MeshData3D had both colors and texture coordinates
@cpp Trade::MeshData @ce had both colors and texture coordinates
- Properly zero-initializing the UTF-8 buffer in
@ref Platform::GlfwApplication::textInputEvent() (see
[mosra/magnum#324](https://github.com/mosra/magnum/pull/324))
@ -1514,9 +1516,9 @@ Released 2019-02-04, tagged as
@ref GL::OpenGLTester library instead. Note that the deprecated
`Magnum/OpenGLTester.h` header is still present, along with all other
deprecated GL-specific headers and APIs in the project root.
- Removed five-argument @ref Trade::MeshData2D and six-argument
@ref Trade::MeshData3D constructors that were deprecated since
February 2017. Use the full six/seven-argument versions instead.
- Removed five-argument @cpp Trade::MeshData2D @ce and six-argument
@cpp Trade::MeshData3D @ce constructors that were deprecated since February
2017. Use the full six/seven-argument versions instead.
- Removed @ref Platform application constructors taking @cpp nullptr @ce,
deprecated in June 2016 for windowless apps and in March 2017 for windowed
apps. Use constructors taking the @ref NoCreate tag instead.
@ -2016,8 +2018,8 @@ Released 2018-10-23, tagged as
clearer naming
- @ref MeshTools::compile() taking a @ref GL::BufferUsage and returning a
tuple was deprecated, use the simpler version taking just
@ref Trade::MeshData2D / @ref Trade::MeshData3D and directly returning a
@ref GL::Mesh instead
@cpp Trade::MeshData2D @ce / @cpp Trade::MeshData3D @ce and directly
returning a @ref GL::Mesh instead
- `Shaders::VertexColor::Color` is deprecated, use the direct
@ref Shaders::VertexColor::Color3 or @ref Shaders::VertexColor::Color4
alternatives instead
@ -2427,9 +2429,8 @@ Released 2018-05-01, tagged as
In particular, @ref GL::Mesh::primitive() now returns
@ref GL::MeshPrimitive instead of @ref Magnum::MeshPrimitive, code
depending on the return type being implicitly convertible to
@ref Magnum::MeshPrimitive may break. IN all other cases,
@ref Trade::MeshData2D::primitive() "Trade::MeshData*D::primitive()" etc.
returns @ref Magnum::MeshPrimitive.
@ref Magnum::MeshPrimitive may break. In all other cases,
`Trade::MeshData*D::primitive()` etc. returns @ref Magnum::MeshPrimitive.
- Configuration value reader/writers are now for only
@ref Magnum::MeshPrimitive and @ref Magnum::MeshIndexType, not for
@ref GL::MeshPrimitive or @ref GL::MeshIndexType
@ -2864,7 +2865,8 @@ a high-level overview.
- New @ref magnum-imageconverter "magnum-imageconverter" utility
- Initial implementation of @ref Trade::CameraData and @ref Trade::LightData
- Vertex color support in @ref Trade::MeshData2D and @ref Trade::MeshData3D
- Vertex color support in @cpp Trade::MeshData2D @ce and
@cpp Trade::MeshData3D @ce
- @ref Trade::AbstractImageConverter member functions were changed to
non-@cpp const @ce to make implementation of complex converter plugins possible
- New @ref Trade::AbstractImageConverter::exportToCompressedImage() plugin
@ -3163,8 +3165,8 @@ a high-level overview.
- `Math::normalize()` and `Math::denormalize()` had confusing naming and thus
are deprecated, use @ref Math::pack() and @ref Math::unpack() from the
@ref Magnum/Math/Packing.h header instead
- @ref Trade::MeshData2D and @ref Trade::MeshData3D constructors without the
`colors` parameter are deprecated, use the full ones instead
- @cpp Trade::MeshData2D @ce and @cpp Trade::MeshData3D @ce constructors
without the `colors` parameter are deprecated, use the full ones instead
- @cpp Shaders::Generic::Color @ce vertex attribute implicit constructor is
deprecated, use a constructor with explicit component count instead
- The bundled @ref std::optional implementation was causing serious conflicts

17
doc/snippets/MagnumTrade.cpp

@ -39,8 +39,6 @@
#include "Magnum/Trade/AnimationData.h"
#include "Magnum/Trade/ImageData.h"
#include "Magnum/Trade/MeshData.h"
#include "Magnum/Trade/MeshData2D.h"
#include "Magnum/Trade/MeshData3D.h"
#include "Magnum/Trade/ObjectData2D.h"
#include "Magnum/Trade/ObjectData3D.h"
#include "Magnum/Trade/PhongMaterialData.h"
@ -50,6 +48,13 @@
#include "Magnum/Shaders/Phong.h"
#endif
#ifdef MAGNUM_BUILD_DEPRECATED
#define _MAGNUM_NO_DEPRECATED_MESHDATA /* So it doesn't yell here */
#include "Magnum/Trade/MeshData2D.h"
#include "Magnum/Trade/MeshData3D.h"
#endif
using namespace Magnum;
using namespace Magnum::Math::Literals;
@ -312,7 +317,9 @@ MeshTools::transformPointsInPlace(Matrix4::scaling(Vector3{2.0f}),
/* [MeshData-usage-mutable] */
}
#ifdef MAGNUM_BUILD_DEPRECATED
{
CORRADE_IGNORE_DEPRECATED_PUSH
Trade::MeshData2D& foo();
Trade::MeshData2D& data = foo();
/* [MeshData2D-transform] */
@ -322,7 +329,9 @@ Matrix3 transformation =
Matrix3::rotation(45.0_degf);
MeshTools::transformPointsInPlace(transformation, data.positions(0));
/* [MeshData2D-transform] */
CORRADE_IGNORE_DEPRECATED_POP
}
#endif
{
Trade::ObjectData2D& baz();
@ -335,7 +344,9 @@ Matrix3 transformation =
static_cast<void>(transformation);
}
#ifdef MAGNUM_BUILD_DEPRECATED
{
CORRADE_IGNORE_DEPRECATED_PUSH
Trade::MeshData3D& bar();
Trade::MeshData3D& data = bar();
/* [MeshData3D-transform] */
@ -345,7 +356,9 @@ Matrix4 transformation =
MeshTools::transformPointsInPlace(transformation, data.positions(0));
MeshTools::transformVectorsInPlace(transformation, data.normals(0));
/* [MeshData3D-transform] */
CORRADE_IGNORE_DEPRECATED_POP
}
#endif
{
Trade::ObjectData3D& fizz();

4
src/Magnum/GL/Mesh.h

@ -196,8 +196,8 @@ layout using @ref setIndexBuffer(). You can also use @ref MeshTools::compressInd
to conveniently compress the indices based on the range used.
There is also @ref MeshTools::compile() function which operates directly on
@ref Trade::MeshData2D / @ref Trade::MeshData3D and returns fully configured
mesh and vertex/index buffers for use with stock shaders.
@ref Trade::MeshData and returns fully configured mesh and vertex/index buffers
for use with stock shaders.
@attention Note that, by default, neither vertex buffers nor index buffer is
managed (e.g. deleted on destruction) by the mesh, so you have to manage

17
src/Magnum/MeshTools/Compile.cpp

@ -27,19 +27,24 @@
#include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/StridedArrayView.h>
#include <Corrade/Containers/ArrayViewStl.h> /** @todo remove once MeshDataXD is gone */
#include "Magnum/GL/Buffer.h"
#include "Magnum/GL/Mesh.h"
#include "Magnum/Math/Vector3.h"
#include "Magnum/Math/Color.h"
#include "Magnum/MeshTools/CompressIndices.h"
#include "Magnum/MeshTools/GenerateNormals.h"
#include "Magnum/MeshTools/Duplicate.h"
#include "Magnum/MeshTools/Interleave.h"
#include "Magnum/Trade/MeshData.h"
#ifdef MAGNUM_BUILD_DEPRECATED
#include <Corrade/Containers/ArrayViewStl.h>
#include "Magnum/Math/Color.h"
#include "Magnum/MeshTools/CompressIndices.h"
#define _MAGNUM_NO_DEPRECATED_MESHDATA /* So it doesn't yell here */
#include "Magnum/Trade/MeshData2D.h"
#include "Magnum/Trade/MeshData3D.h"
#endif
/* This header is included only privately and doesn't introduce any linker
dependency, thus it's completely safe */
@ -191,6 +196,8 @@ GL::Mesh compile(const Trade::MeshData& meshData, GL::Buffer&& indices, GL::Buff
return mesh;
}
#ifdef MAGNUM_BUILD_DEPRECATED
CORRADE_IGNORE_DEPRECATED_PUSH
GL::Mesh compile(const Trade::MeshData2D& meshData) {
GL::Mesh mesh;
mesh.setPrimitive(meshData.primitive());
@ -264,13 +271,11 @@ GL::Mesh compile(const Trade::MeshData2D& meshData) {
return mesh;
}
#ifdef MAGNUM_BUILD_DEPRECATED
std::tuple<GL::Mesh, std::unique_ptr<GL::Buffer>, std::unique_ptr<GL::Buffer>> compile(const Trade::MeshData2D& meshData, GL::BufferUsage) {
return std::make_tuple(compile(meshData),
std::unique_ptr<GL::Buffer>{new GL::Buffer{NoCreate}},
std::unique_ptr<GL::Buffer>{meshData.isIndexed() ? new GL::Buffer{NoCreate} : nullptr});
}
#endif
GL::Mesh compile(const Trade::MeshData3D& meshData, CompileFlags flags) {
GL::Mesh mesh;
@ -426,12 +431,12 @@ GL::Mesh compile(const Trade::MeshData3D& meshData, CompileFlags flags) {
return mesh;
}
#ifdef MAGNUM_BUILD_DEPRECATED
std::tuple<GL::Mesh, std::unique_ptr<GL::Buffer>, std::unique_ptr<GL::Buffer>> compile(const Trade::MeshData3D& meshData, GL::BufferUsage) {
return std::make_tuple(compile(meshData),
std::unique_ptr<GL::Buffer>{new GL::Buffer{NoCreate}},
std::unique_ptr<GL::Buffer>{meshData.isIndexed() ? new GL::Buffer{NoCreate} : nullptr});
}
CORRADE_IGNORE_DEPRECATED_POP
#endif
}}

36
src/Magnum/MeshTools/Compile.h

@ -51,7 +51,7 @@ namespace Magnum { namespace MeshTools {
@brief Mesh compilation flag
@m_since{2019,10}
@see @ref CompileFlags, @ref compile(const Trade::MeshData3D&, CompileFlags)
@see @ref CompileFlags, @ref compile(const Trade::MeshData&, CompileFlags)
*/
enum class CompileFlag: UnsignedByte {
/**
@ -79,7 +79,7 @@ enum class CompileFlag: UnsignedByte {
@brief Mesh compilation flags
@m_since{2019,10}
@see @ref compile(const Trade::MeshData3D&, CompileFlags)
@see @ref compile(const Trade::MeshData&, CompileFlags)
*/
typedef Containers::EnumSet<CompileFlag> CompileFlags;
@ -176,8 +176,11 @@ MAGNUM_MESHTOOLS_EXPORT GL::Mesh compile(const Trade::MeshData& meshData, GL::Bu
*/
MAGNUM_MESHTOOLS_EXPORT GL::Mesh compile(const Trade::MeshData& meshData, GL::Buffer&& indices, GL::Buffer&& vertices);
#ifdef MAGNUM_BUILD_DEPRECATED
/**
@brief Compile 2D mesh data
@m_deprecated_since_latest Use @ref compile(const Trade::MeshData&, CompileFlags)
instead.
Configures a mesh for @ref Shaders::Generic2D shader with vertex buffer and
possibly also an index buffer, if the mesh is indexed. Positions are bound to
@ -200,19 +203,23 @@ greater flexibility.
@see @ref shaders-generic
*/
MAGNUM_MESHTOOLS_EXPORT GL::Mesh compile(const Trade::MeshData2D& meshData);
CORRADE_IGNORE_DEPRECATED_PUSH
CORRADE_DEPRECATED("use compile(const Trade::MeshData&) instead") MAGNUM_MESHTOOLS_EXPORT GL::Mesh compile(const Trade::MeshData2D& meshData);
CORRADE_IGNORE_DEPRECATED_POP
#ifdef MAGNUM_BUILD_DEPRECATED
/** @brief @copybrief compile(const Trade::MeshData2D&)
* @m_deprecated_since{2018,10} Use @ref compile(const Trade::MeshData2D&)
/** @brief Compile 2D mesh data
* @m_deprecated_since{2018,10} Use @ref compile(const Trade::MeshData&)
* instead. The @p usage parameter is ignored and returned buffer
* instances are empty.
*/
CORRADE_DEPRECATED("use compile(const Trade::MeshData2D&) instead") MAGNUM_MESHTOOLS_EXPORT std::tuple<GL::Mesh, std::unique_ptr<GL::Buffer>, std::unique_ptr<GL::Buffer>> compile(const Trade::MeshData2D& meshData, GL::BufferUsage usage);
#endif
CORRADE_IGNORE_DEPRECATED_PUSH
CORRADE_DEPRECATED("use compile(const Trade::MeshData&) instead") MAGNUM_MESHTOOLS_EXPORT std::tuple<GL::Mesh, std::unique_ptr<GL::Buffer>, std::unique_ptr<GL::Buffer>> compile(const Trade::MeshData2D& meshData, GL::BufferUsage usage);
CORRADE_IGNORE_DEPRECATED_POP
/**
@brief Compile 3D mesh data
@m_deprecated_since_latest Use @ref compile(const Trade::MeshData&, CompileFlags)
instead.
Configures mesh for @ref Shaders::Generic3D shader with vertex buffer and
possibly also index buffer, if the mesh is indexed. Positions are bound to
@ -236,15 +243,18 @@ greater flexibility.
@see @ref shaders-generic
*/
MAGNUM_MESHTOOLS_EXPORT GL::Mesh compile(const Trade::MeshData3D& meshData, CompileFlags flags = {});
CORRADE_IGNORE_DEPRECATED_PUSH
CORRADE_DEPRECATED("use compile(const Trade::MeshData&, CompileFlags) instead") MAGNUM_MESHTOOLS_EXPORT GL::Mesh compile(const Trade::MeshData3D& meshData, CompileFlags flags = {});
CORRADE_IGNORE_DEPRECATED_POP
#ifdef MAGNUM_BUILD_DEPRECATED
/** @brief @copybrief compile(const Trade::MeshData3D&, CompileFlags)
* @m_deprecated_since{2018,10} Use @ref compile(const Trade::MeshData3D&, CompileFlags)
/** @brief Compile 3D mesh data
* @m_deprecated_since{2018,10} Use @ref compile(const Trade::MeshData&, CompileFlags)
* instead. The @p usage parameter is ignored and returned buffer
* instances are empty.
*/
CORRADE_DEPRECATED("use compile(const Trade::MeshData3D&) instead") MAGNUM_MESHTOOLS_EXPORT std::tuple<GL::Mesh, std::unique_ptr<GL::Buffer>, std::unique_ptr<GL::Buffer>> compile(const Trade::MeshData3D& meshData, GL::BufferUsage usage);
CORRADE_IGNORE_DEPRECATED_PUSH
CORRADE_DEPRECATED("use compile(const Trade::MeshData&) instead") MAGNUM_MESHTOOLS_EXPORT std::tuple<GL::Mesh, std::unique_ptr<GL::Buffer>, std::unique_ptr<GL::Buffer>> compile(const Trade::MeshData3D& meshData, GL::BufferUsage usage);
CORRADE_IGNORE_DEPRECATED_POP
#endif
}}

40
src/Magnum/MeshTools/Test/CompileGLTest.cpp

@ -50,8 +50,14 @@
#include "Magnum/Shaders/Phong.h"
#include "Magnum/Shaders/VertexColor.h"
#include "Magnum/Trade/AbstractImporter.h"
#include "Magnum/Trade/MeshData.h"
#ifdef MAGNUM_BUILD_DEPRECATED
#define _MAGNUM_NO_DEPRECATED_MESHDATA /* So it doesn't yell here */
#include "Magnum/Trade/MeshData2D.h"
#include "Magnum/Trade/MeshData3D.h"
#endif
#include "configure.h"
@ -81,6 +87,7 @@ struct CompileGLTest: GL::OpenGLTester {
public:
explicit CompileGLTest();
/** @todo remove the template once MeshDataXD is gone */
template<class T> void twoDimensions();
template<class T> void threeDimensions();
void unknownAttribute();
@ -169,14 +176,27 @@ constexpr Color4ub ImageData[] {
CompileGLTest::CompileGLTest() {
addInstancedTests<CompileGLTest>({
&CompileGLTest::twoDimensions<Trade::MeshData>,
&CompileGLTest::twoDimensions<Trade::MeshData>}, Containers::arraySize(Data2D));
#ifdef MAGNUM_BUILD_DEPRECATED
CORRADE_IGNORE_DEPRECATED_PUSH
addInstancedTests<CompileGLTest>({
&CompileGLTest::twoDimensions<Trade::MeshData2D>},
Containers::arraySize(Data2D));
CORRADE_IGNORE_DEPRECATED_POP
#endif
addInstancedTests<CompileGLTest>({
&CompileGLTest::threeDimensions<Trade::MeshData>,
&CompileGLTest::threeDimensions<Trade::MeshData>},
Containers::arraySize(Data3D));
#ifdef MAGNUM_BUILD_DEPRECATED
CORRADE_IGNORE_DEPRECATED_PUSH
addInstancedTests<CompileGLTest>({
&CompileGLTest::threeDimensions<Trade::MeshData3D>},
Containers::arraySize(Data3D));
CORRADE_IGNORE_DEPRECATED_POP
#endif
addTests({&CompileGLTest::unknownAttribute,
&CompileGLTest::generateNormalsNoPosition,
@ -224,12 +244,16 @@ template<class T> struct MeshTypeName;
template<> struct MeshTypeName<Trade::MeshData> {
static const char* name() { return "Trade::MeshData"; }
};
#ifdef MAGNUM_BUILD_DEPRECATED
CORRADE_IGNORE_DEPRECATED_PUSH
template<> struct MeshTypeName<Trade::MeshData2D> {
static const char* name() { return "Trade::MeshData2D"; }
};
template<> struct MeshTypeName<Trade::MeshData3D> {
static const char* name() { return "Trade::MeshData3D"; }
};
CORRADE_IGNORE_DEPRECATED_POP
#endif
template<class T> void CompileGLTest::twoDimensions() {
setTestCaseTemplateName(MeshTypeName<T>::name());
@ -297,7 +321,13 @@ template<class T> void CompileGLTest::twoDimensions() {
MAGNUM_VERIFY_NO_GL_ERROR();
#ifdef MAGNUM_BUILD_DEPRECATED
CORRADE_IGNORE_DEPRECATED_PUSH /** @todo remove once MeshDataXD is gone */
#endif
GL::Mesh mesh = compile(T{std::move(meshData)});
#ifdef MAGNUM_BUILD_DEPRECATED
CORRADE_IGNORE_DEPRECATED_POP
#endif
MAGNUM_VERIFY_NO_GL_ERROR();
@ -431,7 +461,13 @@ template<class T> void CompileGLTest::threeDimensions() {
flags |= CompileFlag::GenerateFlatNormals;
if(data.flags & Flag::GeneratedSmoothNormals)
flags |= CompileFlag::GenerateSmoothNormals;
#ifdef MAGNUM_BUILD_DEPRECATED
CORRADE_IGNORE_DEPRECATED_PUSH /** @todo remove once MeshDataXD is gone */
#endif
GL::Mesh mesh = compile(T{std::move(meshData)}, flags);
#ifdef MAGNUM_BUILD_DEPRECATED
CORRADE_IGNORE_DEPRECATED_POP
#endif
MAGNUM_VERIFY_NO_GL_ERROR();

12
src/Magnum/Trade/AbstractImporter.cpp

@ -46,6 +46,8 @@
#include "Magnum/Trade/TextureData.h"
#ifdef MAGNUM_BUILD_DEPRECATED
#define _MAGNUM_NO_DEPRECATED_MESHDATA /* So it doesn't yell here */
#include "Magnum/Trade/MeshData2D.h"
#include "Magnum/Trade/MeshData3D.h"
#endif
@ -497,17 +499,17 @@ std::string AbstractImporter::mesh2DName(const UnsignedInt id) {
std::string AbstractImporter::doMesh2DName(UnsignedInt) { return {}; }
CORRADE_IGNORE_DEPRECATED_PUSH
Containers::Optional<MeshData2D> AbstractImporter::mesh2D(const UnsignedInt id) {
CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::mesh2D(): no file opened", {});
CORRADE_IGNORE_DEPRECATED_PUSH
CORRADE_ASSERT(id < doMesh2DCount(), "Trade::AbstractImporter::mesh2D(): index" << id << "out of range for" << doMesh2DCount() << "entries", {});
return doMesh2D(id);
CORRADE_IGNORE_DEPRECATED_POP
}
Containers::Optional<MeshData2D> AbstractImporter::doMesh2D(UnsignedInt) {
CORRADE_ASSERT(false, "Trade::AbstractImporter::mesh2D(): not implemented", {});
}
CORRADE_IGNORE_DEPRECATED_POP
UnsignedInt AbstractImporter::mesh3DCount() const {
CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::mesh3DCount(): no file opened", {});
@ -543,21 +545,19 @@ std::string AbstractImporter::doMesh3DName(const UnsignedInt id) {
return doMeshName(id);
}
CORRADE_IGNORE_DEPRECATED_PUSH
Containers::Optional<MeshData3D> AbstractImporter::mesh3D(const UnsignedInt id) {
CORRADE_ASSERT(isOpened(), "Trade::AbstractImporter::mesh3D(): no file opened", {});
CORRADE_IGNORE_DEPRECATED_PUSH
CORRADE_ASSERT(id < doMesh3DCount(), "Trade::AbstractImporter::mesh3D(): index" << id << "out of range for" << doMesh3DCount() << "entries", {});
return doMesh3D(id);
CORRADE_IGNORE_DEPRECATED_POP
}
Containers::Optional<MeshData3D> AbstractImporter::doMesh3D(const UnsignedInt id) {
Containers::Optional<MeshData> out = doMesh(id);
CORRADE_IGNORE_DEPRECATED_PUSH
if(out) return MeshData3D{*out};
CORRADE_IGNORE_DEPRECATED_POP
return Containers::NullOpt;
}
CORRADE_IGNORE_DEPRECATED_POP
#endif
UnsignedInt AbstractImporter::materialCount() const {

4
src/Magnum/Trade/AbstractImporter.h

@ -1049,7 +1049,7 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi
* @see @ref AbstractMaterialData::importerState(),
* @ref AnimationData::importerState(), @ref CameraData::importerState(),
* @ref ImageData::importerState(), @ref LightData::importerState(),
* @ref MeshData2D::importerState(), @ref MeshData3D::importerState(),
* @ref MeshData::importerState(),
* @ref ObjectData2D::importerState(), @ref ObjectData3D::importerState(),
* @ref SceneData::importerState(), @ref TextureData::importerState()
*/
@ -1400,7 +1400,7 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi
* @brief Implementation for @ref mesh3D()
*
* Default implementation returns @ref doMesh() converted to
* @ref MeshData3D for backwards compatibility.
* @cpp MeshData3D @ce for backwards compatibility.
* @m_deprecated_since_latest Implement @ref doMesh() instead.
*/
CORRADE_IGNORE_DEPRECATED_PUSH /* Clang doesn't warn, but GCC does */

28
src/Magnum/Trade/CMakeLists.txt

@ -42,16 +42,6 @@ set(MagnumTrade_GracefulAssert_SRCS
CameraData.cpp
ImageData.cpp
MeshData.cpp
# These have to be here instead of in MagnumTrade_SRCS because they include
# MeshData.h and call (and thus instantiate) various functions with inline
# asserts. We need the linker to pick the variant with graceful asserts for
# tests, and if there would be two different copies, it may happen it picks
# the non-graceful-assert variant, causing the tests to blow up. Happens
# only on the MSVC linker, but let's be safe and do this everywhere.
MeshData2D.cpp
MeshData3D.cpp
ObjectData2D.cpp
ObjectData3D.cpp
PhongMaterialData.cpp)
@ -67,8 +57,6 @@ set(MagnumTrade_HEADERS
ImageData.h
LightData.h
MeshData.h
MeshData2D.h
MeshData3D.h
MeshObjectData2D.h
MeshObjectData3D.h
ObjectData2D.h
@ -83,6 +71,22 @@ set(MagnumTrade_HEADERS
set(MagnumTrade_PRIVATE_HEADERS
Implementation/arrayUtilities.h)
if(MAGNUM_BUILD_DEPRECATED)
list(APPEND MagnumTrade_GracefulAssert_SRCS
# These have to be here instead of in MagnumTrade_SRCS because they
# include MeshData.h and call (and thus instantiate) various functions
# with inline asserts. We need the linker to pick the variant with
# graceful asserts for tests, and if there would be two different
# copies, it may happen it picks the non-graceful-assert variant,
# causing the tests to blow up. Happens only on the MSVC linker, but
# let's be safe and do this everywhere.
MeshData2D.cpp
MeshData3D.cpp)
list(APPEND MagnumTrade_HEADERS
MeshData2D.h
MeshData3D.h)
endif()
if(NOT CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/configure.h)

6
src/Magnum/Trade/MeshData2D.cpp

@ -23,6 +23,8 @@
DEALINGS IN THE SOFTWARE.
*/
#define _MAGNUM_NO_DEPRECATED_MESHDATA /* So it doesn't yell here */
#include "MeshData2D.h"
#include <Corrade/Containers/ArrayViewStl.h>
@ -64,19 +66,23 @@ MeshData2D::MeshData2D(const MeshData& other): _primitive{other.primitive()}, _i
}
#endif
CORRADE_IGNORE_DEPRECATED_PUSH /* MSVC warns here */
MeshData2D::MeshData2D(MeshData2D&&)
#if !defined(__GNUC__) || __GNUC__*100 + __GNUC_MINOR__ != 409
noexcept
#endif
= default;
CORRADE_IGNORE_DEPRECATED_POP
MeshData2D::~MeshData2D() = default;
CORRADE_IGNORE_DEPRECATED_PUSH /* GCC why you warn on return and not on param */
MeshData2D& MeshData2D::operator=(MeshData2D&&)
#if !defined(__GNUC__) || __GNUC__*100 + __GNUC_MINOR__ != 409
noexcept
#endif
= default;
CORRADE_IGNORE_DEPRECATED_POP
std::vector<UnsignedInt>& MeshData2D::indices() {
CORRADE_ASSERT(isIndexed(), "Trade::MeshData2D::indices(): the mesh is not indexed", _indices);

18
src/Magnum/Trade/MeshData2D.h

@ -25,14 +25,25 @@
DEALINGS IN THE SOFTWARE.
*/
#ifdef MAGNUM_BUILD_DEPRECATED
/** @file
* @brief Class @ref Magnum::Trade::MeshData2D
* @m_deprecated_since_latest Use @ref Magnum/Trade/MeshData.h and the
* @ref Magnum::Trade::MeshData "MeshData" class instead.
*/
#endif
#include "Magnum/configure.h"
#ifdef MAGNUM_BUILD_DEPRECATED
#include <vector>
#include "Magnum/Trade/MeshData.h"
#ifndef _MAGNUM_NO_DEPRECATED_MESHDATA
CORRADE_DEPRECATED_FILE("use Magnum/Trade/MeshData.h and the MeshData class instead")
#endif
namespace Magnum { namespace Trade {
/**
@ -48,9 +59,11 @@ directly to vertex positions:
@snippet MagnumTrade.cpp MeshData2D-transform
@m_deprecated_since_latest Use @ref MeshData instead.
@see @ref AbstractImporter::mesh2D(), @ref MeshData3D
*/
class MAGNUM_TRADE_EXPORT MeshData2D {
class CORRADE_DEPRECATED("use MeshData instead") MAGNUM_TRADE_EXPORT MeshData2D {
public:
/**
* @brief Constructor
@ -181,5 +194,8 @@ class MAGNUM_TRADE_EXPORT MeshData2D {
};
}}
#else
#error use Magnum/Trade/MeshData.h and the MeshData class instead
#endif
#endif

7
src/Magnum/Trade/MeshData3D.cpp

@ -23,6 +23,9 @@
DEALINGS IN THE SOFTWARE.
*/
/* There's no better way to disable file deprecation warnings */
#define _MAGNUM_NO_DEPRECATED_MESHDATA
#include "MeshData3D.h"
#include <Corrade/Containers/ArrayViewStl.h>
@ -69,19 +72,23 @@ MeshData3D::MeshData3D(const MeshData& other): _primitive{other.primitive()}, _i
}
#endif
CORRADE_IGNORE_DEPRECATED_PUSH /* MSVC warns here */
MeshData3D::MeshData3D(MeshData3D&&)
#if !defined(__GNUC__) || __GNUC__*100 + __GNUC_MINOR__ != 409
noexcept
#endif
= default;
CORRADE_IGNORE_DEPRECATED_POP
MeshData3D::~MeshData3D() = default;
CORRADE_IGNORE_DEPRECATED_PUSH /* GCC why you warn on return and not on param */
MeshData3D& MeshData3D::operator=(MeshData3D&&)
#if !defined(__GNUC__) || __GNUC__*100 + __GNUC_MINOR__ != 409
noexcept
#endif
= default;
CORRADE_IGNORE_DEPRECATED_POP
std::vector<UnsignedInt>& MeshData3D::indices() {
CORRADE_ASSERT(isIndexed(), "Trade::MeshData3D::indices(): the mesh is not indexed", _indices);

18
src/Magnum/Trade/MeshData3D.h

@ -25,14 +25,25 @@
DEALINGS IN THE SOFTWARE.
*/
#ifdef MAGNUM_BUILD_DEPRECATED
/** @file
* @brief Class @ref Magnum::Trade::MeshData3D
* @m_deprecated_since_latest Use @ref Magnum/Trade/MeshData.h and the
* @ref Magnum::Trade::MeshData "MeshData" class instead.
*/
#endif
#include "Magnum/configure.h"
#ifdef MAGNUM_BUILD_DEPRECATED
#include <vector>
#include "Magnum/Trade/MeshData.h"
#ifndef _MAGNUM_NO_DEPRECATED_MESHDATA
CORRADE_DEPRECATED_FILE("use Magnum/Trade/MeshData.h and the MeshData class instead")
#endif
namespace Magnum { namespace Trade {
/**
@ -48,9 +59,11 @@ to positions and normals:
@snippet MagnumTrade.cpp MeshData3D-transform
@m_deprecated_since_latest Use @ref MeshData instead.
@see @ref AbstractImporter::mesh3D(), @ref MeshData2D
*/
class MAGNUM_TRADE_EXPORT MeshData3D {
class CORRADE_DEPRECATED("use MeshData instead") MAGNUM_TRADE_EXPORT MeshData3D {
public:
/**
* @brief Constructor
@ -198,5 +211,8 @@ class MAGNUM_TRADE_EXPORT MeshData3D {
};
}}
#else
#error use Magnum/Trade/MeshData.h and the MeshData class instead
#endif
#endif

2
src/Magnum/Trade/Test/AbstractImporterTest.cpp

@ -46,6 +46,8 @@
#include "Magnum/Trade/TextureData.h"
#ifdef MAGNUM_BUILD_DEPRECATED
#define _MAGNUM_NO_DEPRECATED_MESHDATA /* So it doesn't yell here */
#include "Magnum/Trade/MeshData2D.h"
#include "Magnum/Trade/MeshData3D.h"
#endif

14
src/Magnum/Trade/Test/CMakeLists.txt

@ -49,8 +49,6 @@ corrade_add_test(TradeImageDataTest ImageDataTest.cpp LIBRARIES MagnumTradeTestL
corrade_add_test(TradeLightDataTest LightDataTest.cpp LIBRARIES MagnumTrade)
corrade_add_test(TradeMaterialDataTest MaterialDataTest.cpp LIBRARIES MagnumTradeTestLib)
corrade_add_test(TradeMeshDataTest MeshDataTest.cpp LIBRARIES MagnumTradeTestLib)
corrade_add_test(TradeMeshData2DTest MeshData2DTest.cpp LIBRARIES MagnumTrade)
corrade_add_test(TradeMeshData3DTest MeshData3DTest.cpp LIBRARIES MagnumTrade)
corrade_add_test(TradeObjectData2DTest ObjectData2DTest.cpp LIBRARIES MagnumTradeTestLib)
corrade_add_test(TradeObjectData3DTest ObjectData3DTest.cpp LIBRARIES MagnumTradeTestLib)
corrade_add_test(TradeSceneDataTest SceneDataTest.cpp LIBRARIES MagnumTrade)
@ -69,10 +67,18 @@ set_target_properties(
TradeImageDataTest
TradeLightDataTest
TradeMaterialDataTest
TradeMeshData2DTest
TradeMeshData3DTest
TradeObjectData2DTest
TradeObjectData3DTest
TradeSceneDataTest
TradeTextureDataTest
PROPERTIES FOLDER "Magnum/Trade/Test")
if(MAGNUM_BUILD_DEPRECATED)
corrade_add_test(TradeMeshData2DTest MeshData2DTest.cpp LIBRARIES MagnumTrade)
corrade_add_test(TradeMeshData3DTest MeshData3DTest.cpp LIBRARIES MagnumTrade)
set_target_properties(
TradeMeshData2DTest
TradeMeshData3DTest
PROPERTIES FOLDER "Magnum/Trade/Test")
endif()

9
src/Magnum/Trade/Test/MeshData2DTest.cpp

@ -23,6 +23,9 @@
DEALINGS IN THE SOFTWARE.
*/
/* There's no better way to disable file deprecation warnings */
#define _MAGNUM_NO_DEPRECATED_MESHDATA
#include <Corrade/TestSuite/Tester.h>
#include "Magnum/Mesh.h"
@ -42,6 +45,8 @@ struct MeshData2DTest: TestSuite::Tester {
void constructMove();
};
CORRADE_IGNORE_DEPRECATED_PUSH
using namespace Math::Literals;
const UnsignedByte Indices[]{12, 1, 0};
@ -59,7 +64,6 @@ const struct Vertex {
};
const int State = 3;
CORRADE_IGNORE_DEPRECATED_PUSH
struct {
const char* name;
const MeshData2D data, dataNonIndexed;
@ -103,7 +107,6 @@ struct {
}, &State}
}
};
CORRADE_IGNORE_DEPRECATED_POP
MeshData2DTest::MeshData2DTest() {
addInstancedTests({&MeshData2DTest::construct,
@ -220,6 +223,8 @@ void MeshData2DTest::constructMove() {
CORRADE_COMPARE(d.importerState(), &a);
}
CORRADE_IGNORE_DEPRECATED_POP
}}}}
CORRADE_TEST_MAIN(Magnum::Trade::Test::MeshData2DTest)

9
src/Magnum/Trade/Test/MeshData3DTest.cpp

@ -23,6 +23,9 @@
DEALINGS IN THE SOFTWARE.
*/
/* There's no better way to disable file deprecation warnings */
#define _MAGNUM_NO_DEPRECATED_MESHDATA
#include <Corrade/TestSuite/Tester.h>
#include "Magnum/Mesh.h"
@ -43,6 +46,8 @@ struct MeshData3DTest: TestSuite::Tester {
void constructMove();
};
CORRADE_IGNORE_DEPRECATED_PUSH
using namespace Math::Literals;
const UnsignedByte Indices[]{12, 1, 0};
@ -63,7 +68,6 @@ const struct Vertex {
};
const int State = 3;
CORRADE_IGNORE_DEPRECATED_PUSH
struct {
const char* name;
const MeshData3D data, dataNonIndexed;
@ -113,7 +117,6 @@ struct {
}, &State}
}
};
CORRADE_IGNORE_DEPRECATED_POP
MeshData3DTest::MeshData3DTest() {
addInstancedTests({&MeshData3DTest::construct,
@ -254,6 +257,8 @@ void MeshData3DTest::constructMove() {
CORRADE_COMPARE(d.importerState(), &a);
}
CORRADE_IGNORE_DEPRECATED_POP
}}}}
CORRADE_TEST_MAIN(Magnum::Trade::Test::MeshData3DTest)

6
src/Magnum/Trade/Trade.h

@ -74,8 +74,10 @@ class MeshIndexData;
class MeshAttributeData;
class MeshData;
class MeshData2D;
class MeshData3D;
#ifdef MAGNUM_BUILD_DEPRECATED
class CORRADE_DEPRECATED("use MeshData instead") MeshData2D;
class CORRADE_DEPRECATED("use MeshData instead") MeshData3D;
#endif
class MeshObjectData2D;
class MeshObjectData3D;
class ObjectData2D;

Loading…
Cancel
Save