Browse Source

AnySceneImporter: fix meshAttribute[For]Name() without a file opened.

pull/570/head
Vladimír Vondruš 4 years ago
parent
commit
36127c02e0
  1. 4
      doc/changelog.dox
  2. 12
      src/MagnumPlugins/AnySceneImporter/AnySceneImporter.cpp
  3. 4
      src/MagnumPlugins/AnySceneImporter/AnySceneImporter.h

4
doc/changelog.dox

@ -592,6 +592,10 @@ See also:
[mosra/magnum#523](https://github.com/mosra/magnum/issues/523).
- `UseEmscripten` is no longer implicitly included on Emscripten as it's not
needed for anything (see [mosra/magnum#490](https://github.com/mosra/magnum/issues/490))
- Fixed an assertion in @relativeref{Trade,AnySceneImporter} when
@relativeref{Trade::AbstractImporter,meshAttributeName()} or
@relativeref{Trade::AbstractImporter,meshAttributeForName()} was called
without a file opened
- @ref Trade::ObjImporter "ObjImporter" uses exceptions internally and needs
an explicit exception-enabling flag when built with Emscripten 1.39.0 and
newer

12
src/MagnumPlugins/AnySceneImporter/AnySceneImporter.cpp

@ -231,8 +231,16 @@ Int AnySceneImporter::doMeshForName(const Containers::StringView name) { return
Containers::String AnySceneImporter::doMeshName(const UnsignedInt id) { return _in->meshName(id); }
Containers::Optional<MeshData> AnySceneImporter::doMesh(const UnsignedInt id, const UnsignedInt level) { return _in->mesh(id, level); }
MeshAttribute AnySceneImporter::doMeshAttributeForName(const Containers::StringView name) { return _in->meshAttributeForName(name); }
Containers::String AnySceneImporter::doMeshAttributeName(const UnsignedShort id) { return _in->meshAttributeName(meshAttributeCustom(id)); }
MeshAttribute AnySceneImporter::doMeshAttributeForName(const Containers::StringView name) {
/* This API can be called even if no file is opened, in that case return
an invalid ID */
return _in ? _in->meshAttributeForName(name) : MeshAttribute{};
}
Containers::String AnySceneImporter::doMeshAttributeName(const UnsignedShort id) {
/* This API can be called even if no file is opened, in that case return
an invalid ID */
return _in ? _in->meshAttributeName(meshAttributeCustom(id)) : Containers::String{};
}
#ifdef MAGNUM_BUILD_DEPRECATED
CORRADE_IGNORE_DEPRECATED_PUSH

4
src/MagnumPlugins/AnySceneImporter/AnySceneImporter.h

@ -146,6 +146,10 @@ Calls to the @ref animation(), @ref scene(), @ref light(), @ref camera(),
and corresponding count-/name-related functions are then proxied to the
concrete implementation. The @ref close() function closes and discards the
internally instantiated plugin; @ref isOpened() works as usual.
While the @ref meshAttributeName() and @ref meshAttributeForName() APIs can
be called without a file opened, they return an empty string or an invalid
attribute in that case.
*/
class MAGNUM_ANYSCENEIMPORTER_EXPORT AnySceneImporter: public AbstractImporter {
public:

Loading…
Cancel
Save