Browse Source

Trade: use 64-bit values in object-oriented SceneData APIs.

Mostly just to avoid the return types changing to incompatible types in
the future, breaking existing code. The internals are currently not
fully ready to operate with 64-bit object IDs, especially the AsArray()
APIs -- those I will have to solve in the future somehow. Returning
64-bit values in the pairs would add four byte padding after basically
each value, which is way too wasteful for the common case.

The Into() APIs could eventually get 64-bit overloads though.
pull/525/head
Vladimír Vondruš 5 years ago
parent
commit
dd9f4747b7
  1. 8
      src/Magnum/Trade/AbstractImporter.cpp
  2. 48
      src/Magnum/Trade/SceneData.cpp
  3. 36
      src/Magnum/Trade/SceneData.h
  4. 18
      src/Magnum/Trade/Test/SceneDataTest.cpp
  5. 10
      src/Magnum/Trade/Test/SceneToolsTest.cpp

8
src/Magnum/Trade/AbstractImporter.cpp

@ -621,7 +621,7 @@ std::string AbstractImporter::doObject2DName(const UnsignedInt id) {
_cachedScenes->scenes[i]->mappingBound() <= id) _cachedScenes->scenes[i]->mappingBound() <= id)
continue; continue;
if(Containers::Optional<Int> parent = _cachedScenes->scenes[i]->parentFor(id)) if(Containers::Optional<Long> parent = _cachedScenes->scenes[i]->parentFor(id))
return doObjectName(*parent); return doObjectName(*parent);
} }
@ -678,7 +678,7 @@ Containers::Pointer<ObjectData2D> AbstractImporter::doObject2D(const UnsignedInt
std::vector<UnsignedInt> children; /* not const so we can move it */ std::vector<UnsignedInt> children; /* not const so we can move it */
{ {
Containers::Array<UnsignedInt> childrenArray = scene.childrenFor(id); Containers::Array<UnsignedLong> childrenArray = scene.childrenFor(id);
children = {childrenArray.begin(), childrenArray.end()}; children = {childrenArray.begin(), childrenArray.end()};
} }
const Containers::Array<Containers::Pair<UnsignedInt, Int>> mesh = scene.meshesMaterialsFor(id); const Containers::Array<Containers::Pair<UnsignedInt, Int>> mesh = scene.meshesMaterialsFor(id);
@ -799,7 +799,7 @@ std::string AbstractImporter::doObject3DName(const UnsignedInt id) {
_cachedScenes->scenes[i]->mappingBound() <= id) _cachedScenes->scenes[i]->mappingBound() <= id)
continue; continue;
if(Containers::Optional<Int> parent = _cachedScenes->scenes[i]->parentFor(id)) if(Containers::Optional<Long> parent = _cachedScenes->scenes[i]->parentFor(id))
return doObjectName(*parent); return doObjectName(*parent);
} }
@ -856,7 +856,7 @@ Containers::Pointer<ObjectData3D> AbstractImporter::doObject3D(const UnsignedInt
std::vector<UnsignedInt> children; /* not const so we can move it */ std::vector<UnsignedInt> children; /* not const so we can move it */
{ {
Containers::Array<UnsignedInt> childrenArray = scene.childrenFor(id); Containers::Array<UnsignedLong> childrenArray = scene.childrenFor(id);
children = {childrenArray.begin(), childrenArray.end()}; children = {childrenArray.begin(), childrenArray.end()};
} }
const Containers::Array<Containers::Pair<UnsignedInt, Int>> mesh = scene.meshesMaterialsFor(id); const Containers::Array<Containers::Pair<UnsignedInt, Int>> mesh = scene.meshesMaterialsFor(id);

48
src/Magnum/Trade/SceneData.cpp

@ -895,7 +895,7 @@ namespace {
/* The `objects` view is already adjusted for `offset`, the offset is needed /* The `objects` view is already adjusted for `offset`, the offset is needed
only to return the correct value for ImplicitMapping */ only to return the correct value for ImplicitMapping */
template<class T> std::size_t findObject(const SceneFieldFlags flags, const Containers::StridedArrayView1D<const void>& mapping, const std::size_t offset, const UnsignedInt object) { template<class T> std::size_t findObject(const SceneFieldFlags flags, const Containers::StridedArrayView1D<const void>& mapping, const std::size_t offset, const UnsignedLong object) {
const std::size_t max = mapping.size(); const std::size_t max = mapping.size();
/* Implicit mapping, position equals object ID (if in bounds) and thus an /* Implicit mapping, position equals object ID (if in bounds) and thus an
@ -926,7 +926,7 @@ template<class T> std::size_t findObject(const SceneFieldFlags flags, const Cont
} }
std::size_t SceneData::findFieldObjectOffsetInternal(const SceneFieldData& field, const UnsignedInt object, const std::size_t offset) const { std::size_t SceneData::findFieldObjectOffsetInternal(const SceneFieldData& field, const UnsignedLong object, const std::size_t offset) const {
const Containers::StridedArrayView1D<const void> mapping = fieldDataMappingViewInternal(field, offset, field._size - offset); const Containers::StridedArrayView1D<const void> mapping = fieldDataMappingViewInternal(field, offset, field._size - offset);
if(field._mappingType == SceneMappingType::UnsignedInt) if(field._mappingType == SceneMappingType::UnsignedInt)
return offset + findObject<UnsignedInt>(field._flags, mapping, offset, object); return offset + findObject<UnsignedInt>(field._flags, mapping, offset, object);
@ -939,7 +939,7 @@ std::size_t SceneData::findFieldObjectOffsetInternal(const SceneFieldData& field
else CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ else CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
} }
Containers::Optional<std::size_t> SceneData::findFieldObjectOffset(const UnsignedInt fieldId, const UnsignedInt object, const std::size_t offset) const { Containers::Optional<std::size_t> SceneData::findFieldObjectOffset(const UnsignedInt fieldId, const UnsignedLong object, const std::size_t offset) const {
CORRADE_ASSERT(object < _mappingBound, CORRADE_ASSERT(object < _mappingBound,
"Trade::SceneData::findFieldObjectOffset(): object" << object << "out of bounds for" << _mappingBound << "objects", {}); "Trade::SceneData::findFieldObjectOffset(): object" << object << "out of bounds for" << _mappingBound << "objects", {});
CORRADE_ASSERT(fieldId < _fields.size(), CORRADE_ASSERT(fieldId < _fields.size(),
@ -953,7 +953,7 @@ Containers::Optional<std::size_t> SceneData::findFieldObjectOffset(const Unsigne
return found == field._size ? Containers::Optional<std::size_t>{} : found; return found == field._size ? Containers::Optional<std::size_t>{} : found;
} }
Containers::Optional<std::size_t> SceneData::findFieldObjectOffset(const SceneField fieldName, const UnsignedInt object, const std::size_t offset) const { Containers::Optional<std::size_t> SceneData::findFieldObjectOffset(const SceneField fieldName, const UnsignedLong object, const std::size_t offset) const {
CORRADE_ASSERT(object < _mappingBound, CORRADE_ASSERT(object < _mappingBound,
"Trade::SceneData::findFieldObjectOffset(): object" << object << "out of bounds for" << _mappingBound << "objects", {}); "Trade::SceneData::findFieldObjectOffset(): object" << object << "out of bounds for" << _mappingBound << "objects", {});
@ -969,7 +969,7 @@ Containers::Optional<std::size_t> SceneData::findFieldObjectOffset(const SceneFi
return found == field._size ? Containers::Optional<std::size_t>{} : found; return found == field._size ? Containers::Optional<std::size_t>{} : found;
} }
std::size_t SceneData::fieldObjectOffset(const UnsignedInt fieldId, const UnsignedInt object, const std::size_t offset) const { std::size_t SceneData::fieldObjectOffset(const UnsignedInt fieldId, const UnsignedLong object, const std::size_t offset) const {
CORRADE_ASSERT(object < _mappingBound, CORRADE_ASSERT(object < _mappingBound,
"Trade::SceneData::fieldObjectOffset(): object" << object << "out of bounds for" << _mappingBound << "objects", {}); "Trade::SceneData::fieldObjectOffset(): object" << object << "out of bounds for" << _mappingBound << "objects", {});
CORRADE_ASSERT(fieldId < _fields.size(), CORRADE_ASSERT(fieldId < _fields.size(),
@ -985,7 +985,7 @@ std::size_t SceneData::fieldObjectOffset(const UnsignedInt fieldId, const Unsign
return found; return found;
} }
std::size_t SceneData::fieldObjectOffset(const SceneField fieldName, const UnsignedInt object, const std::size_t offset) const { std::size_t SceneData::fieldObjectOffset(const SceneField fieldName, const UnsignedLong object, const std::size_t offset) const {
CORRADE_ASSERT(object < _mappingBound, CORRADE_ASSERT(object < _mappingBound,
"Trade::SceneData::fieldObjectOffset(): object" << object << "out of bounds for" << _mappingBound << "objects", {}); "Trade::SceneData::fieldObjectOffset(): object" << object << "out of bounds for" << _mappingBound << "objects", {});
@ -1003,7 +1003,7 @@ std::size_t SceneData::fieldObjectOffset(const SceneField fieldName, const Unsig
return found; return found;
} }
bool SceneData::hasFieldObject(const UnsignedInt fieldId, const UnsignedInt object) const { bool SceneData::hasFieldObject(const UnsignedInt fieldId, const UnsignedLong object) const {
CORRADE_ASSERT(object < _mappingBound, CORRADE_ASSERT(object < _mappingBound,
"Trade::SceneData::hasFieldObject(): object" << object << "out of bounds for" << _mappingBound << "objects", {}); "Trade::SceneData::hasFieldObject(): object" << object << "out of bounds for" << _mappingBound << "objects", {});
CORRADE_ASSERT(fieldId < _fields.size(), CORRADE_ASSERT(fieldId < _fields.size(),
@ -1013,7 +1013,7 @@ bool SceneData::hasFieldObject(const UnsignedInt fieldId, const UnsignedInt obje
return findFieldObjectOffsetInternal(field, object, 0) != field._size; return findFieldObjectOffsetInternal(field, object, 0) != field._size;
} }
bool SceneData::hasFieldObject(const SceneField fieldName, const UnsignedInt object) const { bool SceneData::hasFieldObject(const SceneField fieldName, const UnsignedLong object) const {
CORRADE_ASSERT(object < _mappingBound, CORRADE_ASSERT(object < _mappingBound,
"Trade::SceneData::hasFieldObject(): object" << object << "out of bounds for" << _mappingBound << "objects", {}); "Trade::SceneData::hasFieldObject(): object" << object << "out of bounds for" << _mappingBound << "objects", {});
@ -2122,7 +2122,7 @@ Containers::Array<Containers::Pair<UnsignedInt, const void*>> SceneData::importe
return out; return out;
} }
Containers::Optional<Int> SceneData::parentFor(const UnsignedInt object) const { Containers::Optional<Long> SceneData::parentFor(const UnsignedLong object) const {
CORRADE_ASSERT(object < _mappingBound, CORRADE_ASSERT(object < _mappingBound,
"Trade::SceneData::parentFor(): object" << object << "out of bounds for" << _mappingBound << "objects", {}); "Trade::SceneData::parentFor(): object" << object << "out of bounds for" << _mappingBound << "objects", {});
@ -2138,7 +2138,7 @@ Containers::Optional<Int> SceneData::parentFor(const UnsignedInt object) const {
return *index; return *index;
} }
Containers::Array<UnsignedInt> SceneData::childrenFor(const Int object) const { Containers::Array<UnsignedLong> SceneData::childrenFor(const Long object) const {
CORRADE_ASSERT(object >= -1 && object < Long(_mappingBound), CORRADE_ASSERT(object >= -1 && object < Long(_mappingBound),
"Trade::SceneData::childrenFor(): object" << object << "out of bounds for" << _mappingBound << "objects", {}); "Trade::SceneData::childrenFor(): object" << object << "out of bounds for" << _mappingBound << "objects", {});
@ -2148,11 +2148,15 @@ Containers::Array<UnsignedInt> SceneData::childrenFor(const Int object) const {
const SceneFieldData& parentField = _fields[parentFieldId]; const SceneFieldData& parentField = _fields[parentFieldId];
/* Collect IDs of all objects that reference this object */ /* Collect IDs of all objects that reference this object */
Containers::Array<UnsignedInt> out; Containers::Array<UnsignedLong> out;
for(std::size_t offset = 0; offset != parentField.size(); ++offset) { for(std::size_t offset = 0; offset != parentField.size(); ++offset) {
Int parentIndex[1]; Int parentIndex[1];
parentsIntoInternal(parentFieldId, offset, parentIndex); parentsIntoInternal(parentFieldId, offset, parentIndex);
if(*parentIndex == object) { if(*parentIndex == object) {
/** @todo this drops the upper 64 bits, might be a problem
eventually (at this point it's more important to have an API
that won't change the return types in the future, breaking
existing code) */
UnsignedInt child[1]; UnsignedInt child[1];
/** @todo bleh slow, use the children <-> parent field proxying /** @todo bleh slow, use the children <-> parent field proxying
when implemented */ when implemented */
@ -2164,7 +2168,7 @@ Containers::Array<UnsignedInt> SceneData::childrenFor(const Int object) const {
return out; return out;
} }
Containers::Optional<Matrix3> SceneData::transformation2DFor(const UnsignedInt object) const { Containers::Optional<Matrix3> SceneData::transformation2DFor(const UnsignedLong object) const {
CORRADE_ASSERT(object < _mappingBound, CORRADE_ASSERT(object < _mappingBound,
"Trade::SceneData::transformation2DFor(): object" << object << "out of bounds for" << _mappingBound << "objects", {}); "Trade::SceneData::transformation2DFor(): object" << object << "out of bounds for" << _mappingBound << "objects", {});
@ -2185,7 +2189,7 @@ Containers::Optional<Matrix3> SceneData::transformation2DFor(const UnsignedInt o
return *transformation; return *transformation;
} }
Containers::Optional<Containers::Triple<Vector2, Complex, Vector2>> SceneData::translationRotationScaling2DFor(const UnsignedInt object) const { Containers::Optional<Containers::Triple<Vector2, Complex, Vector2>> SceneData::translationRotationScaling2DFor(const UnsignedLong object) const {
CORRADE_ASSERT(object < _mappingBound, CORRADE_ASSERT(object < _mappingBound,
"Trade::SceneData::translationRotationScaling2DFor(): object" << object << "out of bounds for" << _mappingBound << "objects", {}); "Trade::SceneData::translationRotationScaling2DFor(): object" << object << "out of bounds for" << _mappingBound << "objects", {});
@ -2208,7 +2212,7 @@ Containers::Optional<Containers::Triple<Vector2, Complex, Vector2>> SceneData::t
return {InPlaceInit, *translation, *rotation, *scaling}; return {InPlaceInit, *translation, *rotation, *scaling};
} }
Containers::Optional<Matrix4> SceneData::transformation3DFor(const UnsignedInt object) const { Containers::Optional<Matrix4> SceneData::transformation3DFor(const UnsignedLong object) const {
CORRADE_ASSERT(object < _mappingBound, CORRADE_ASSERT(object < _mappingBound,
"Trade::SceneData::transformation3DFor(): object" << object << "out of bounds for" << _mappingBound << "objects", {}); "Trade::SceneData::transformation3DFor(): object" << object << "out of bounds for" << _mappingBound << "objects", {});
@ -2229,7 +2233,7 @@ Containers::Optional<Matrix4> SceneData::transformation3DFor(const UnsignedInt o
return *transformation; return *transformation;
} }
Containers::Optional<Containers::Triple<Vector3, Quaternion, Vector3>> SceneData::translationRotationScaling3DFor(const UnsignedInt object) const { Containers::Optional<Containers::Triple<Vector3, Quaternion, Vector3>> SceneData::translationRotationScaling3DFor(const UnsignedLong object) const {
CORRADE_ASSERT(object < _mappingBound, CORRADE_ASSERT(object < _mappingBound,
"Trade::SceneData::translationRotationScaling3DFor(): object" << object << "out of bounds for" << _mappingBound << "objects", {}); "Trade::SceneData::translationRotationScaling3DFor(): object" << object << "out of bounds for" << _mappingBound << "objects", {});
@ -2252,7 +2256,7 @@ Containers::Optional<Containers::Triple<Vector3, Quaternion, Vector3>> SceneData
return {InPlaceInit, *translation, *rotation, *scaling}; return {InPlaceInit, *translation, *rotation, *scaling};
} }
Containers::Array<Containers::Pair<UnsignedInt, Int>> SceneData::meshesMaterialsFor(const UnsignedInt object) const { Containers::Array<Containers::Pair<UnsignedInt, Int>> SceneData::meshesMaterialsFor(const UnsignedLong object) const {
CORRADE_ASSERT(object < _mappingBound, CORRADE_ASSERT(object < _mappingBound,
"Trade::SceneData::meshesMaterialsFor(): object" << object << "out of bounds for" << _mappingBound << "objects", {}); "Trade::SceneData::meshesMaterialsFor(): object" << object << "out of bounds for" << _mappingBound << "objects", {});
@ -2276,7 +2280,7 @@ Containers::Array<Containers::Pair<UnsignedInt, Int>> SceneData::meshesMaterials
return out; return out;
} }
Containers::Array<UnsignedInt> SceneData::lightsFor(const UnsignedInt object) const { Containers::Array<UnsignedInt> SceneData::lightsFor(const UnsignedLong object) const {
CORRADE_ASSERT(object < _mappingBound, CORRADE_ASSERT(object < _mappingBound,
"Trade::SceneData::lightsFor(): object" << object << "out of bounds for" << _mappingBound << "objects", {}); "Trade::SceneData::lightsFor(): object" << object << "out of bounds for" << _mappingBound << "objects", {});
@ -2299,7 +2303,7 @@ Containers::Array<UnsignedInt> SceneData::lightsFor(const UnsignedInt object) co
return out; return out;
} }
Containers::Array<UnsignedInt> SceneData::camerasFor(const UnsignedInt object) const { Containers::Array<UnsignedInt> SceneData::camerasFor(const UnsignedLong object) const {
CORRADE_ASSERT(object < _mappingBound, CORRADE_ASSERT(object < _mappingBound,
"Trade::SceneData::camerasFor(): object" << object << "out of bounds for" << _mappingBound << "objects", {}); "Trade::SceneData::camerasFor(): object" << object << "out of bounds for" << _mappingBound << "objects", {});
@ -2322,7 +2326,7 @@ Containers::Array<UnsignedInt> SceneData::camerasFor(const UnsignedInt object) c
return out; return out;
} }
Containers::Array<UnsignedInt> SceneData::skinsFor(const UnsignedInt object) const { Containers::Array<UnsignedInt> SceneData::skinsFor(const UnsignedLong object) const {
CORRADE_ASSERT(object < _mappingBound, CORRADE_ASSERT(object < _mappingBound,
"Trade::SceneData::skinsFor(): object" << object << "out of bounds for" << _mappingBound << "objects", {}); "Trade::SceneData::skinsFor(): object" << object << "out of bounds for" << _mappingBound << "objects", {});
@ -2345,7 +2349,7 @@ Containers::Array<UnsignedInt> SceneData::skinsFor(const UnsignedInt object) con
return out; return out;
} }
Containers::Optional<const void*> SceneData::importerStateFor(const UnsignedInt object) const { Containers::Optional<const void*> SceneData::importerStateFor(const UnsignedLong object) const {
CORRADE_ASSERT(object < _mappingBound, CORRADE_ASSERT(object < _mappingBound,
"Trade::SceneData::importerStateFor(): object" << object << "out of bounds for" << _mappingBound << "objects", {}); "Trade::SceneData::importerStateFor(): object" << object << "out of bounds for" << _mappingBound << "objects", {});
@ -2370,7 +2374,7 @@ std::vector<UnsignedInt> SceneData::children2D() const {
if(!hasField(SceneField::Parent)) if(!hasField(SceneField::Parent))
Warning{} << "Trade::SceneData::children2D(): no parent field present, returned array will be empty"; Warning{} << "Trade::SceneData::children2D(): no parent field present, returned array will be empty";
const Containers::Array<UnsignedInt> children = childrenFor(-1); const Containers::Array<UnsignedLong> children = childrenFor(-1);
return {children.begin(), children.end()}; return {children.begin(), children.end()};
} }
@ -2382,7 +2386,7 @@ std::vector<UnsignedInt> SceneData::children3D() const {
if(!hasField(SceneField::Parent)) if(!hasField(SceneField::Parent))
Warning{} << "Trade::SceneData::children3D(): no parent field present, returned array will be empty"; Warning{} << "Trade::SceneData::children3D(): no parent field present, returned array will be empty";
const Containers::Array<UnsignedInt> children = childrenFor(-1); const Containers::Array<UnsignedLong> children = childrenFor(-1);
return {children.begin(), children.end()}; return {children.begin(), children.end()};
} }
#endif #endif

36
src/Magnum/Trade/SceneData.h

@ -1510,7 +1510,7 @@ class MAGNUM_TRADE_EXPORT SceneData {
* @see @ref hasFieldObject(UnsignedInt, UnsignedInt) const, * @see @ref hasFieldObject(UnsignedInt, UnsignedInt) const,
* @ref fieldObjectOffset(UnsignedInt, UnsignedInt, std::size_t) const * @ref fieldObjectOffset(UnsignedInt, UnsignedInt, std::size_t) const
*/ */
Containers::Optional<std::size_t> findFieldObjectOffset(UnsignedInt fieldId, UnsignedInt object, std::size_t offset = 0) const; Containers::Optional<std::size_t> findFieldObjectOffset(UnsignedInt fieldId, UnsignedLong object, std::size_t offset = 0) const;
/** /**
* @brief Find offset of an object in given named field * @brief Find offset of an object in given named field
@ -1532,7 +1532,7 @@ class MAGNUM_TRADE_EXPORT SceneData {
* @see @ref hasField(), @ref hasFieldObject(SceneField, UnsignedInt) const, * @see @ref hasField(), @ref hasFieldObject(SceneField, UnsignedInt) const,
* @ref fieldObjectOffset(SceneField, UnsignedInt, std::size_t) const * @ref fieldObjectOffset(SceneField, UnsignedInt, std::size_t) const
*/ */
Containers::Optional<std::size_t> findFieldObjectOffset(SceneField fieldName, UnsignedInt object, std::size_t offset = 0) const; Containers::Optional<std::size_t> findFieldObjectOffset(SceneField fieldName, UnsignedLong object, std::size_t offset = 0) const;
/** /**
* @brief Offset of an object in given field * @brief Offset of an object in given field
@ -1545,7 +1545,7 @@ class MAGNUM_TRADE_EXPORT SceneData {
* You can also use @ref fieldObjectOffset(SceneField, UnsignedInt, std::size_t) const * You can also use @ref fieldObjectOffset(SceneField, UnsignedInt, std::size_t) const
* to directly get offset of an object in given named field. * to directly get offset of an object in given named field.
*/ */
std::size_t fieldObjectOffset(UnsignedInt fieldId, UnsignedInt object, std::size_t offset = 0) const; std::size_t fieldObjectOffset(UnsignedInt fieldId, UnsignedLong object, std::size_t offset = 0) const;
/** /**
* @brief Offset of an object in given named field * @brief Offset of an object in given named field
@ -1555,7 +1555,7 @@ class MAGNUM_TRADE_EXPORT SceneData {
* but @p object is additionally expected to be present in @p fieldName * but @p object is additionally expected to be present in @p fieldName
* starting at @p offset. * starting at @p offset.
*/ */
std::size_t fieldObjectOffset(SceneField fieldName, UnsignedInt object, std::size_t offset = 0) const; std::size_t fieldObjectOffset(SceneField fieldName, UnsignedLong object, std::size_t offset = 0) const;
/** /**
* @brief Whether a scene field has given object * @brief Whether a scene field has given object
@ -1564,7 +1564,7 @@ class MAGNUM_TRADE_EXPORT SceneData {
* The @p fieldId is expected to be smaller than @ref fieldCount() and * The @p fieldId is expected to be smaller than @ref fieldCount() and
* @p object smaller than @ref mappingBound(). * @p object smaller than @ref mappingBound().
*/ */
bool hasFieldObject(UnsignedInt fieldId, UnsignedInt object) const; bool hasFieldObject(UnsignedInt fieldId, UnsignedLong object) const;
/** /**
* @brief Whether a named scene field has given object * @brief Whether a named scene field has given object
@ -1574,7 +1574,7 @@ class MAGNUM_TRADE_EXPORT SceneData {
* be smaller than @ref mappingBound(). * be smaller than @ref mappingBound().
* @see @ref hasField() * @see @ref hasField()
*/ */
bool hasFieldObject(SceneField fieldName, UnsignedInt object) const; bool hasFieldObject(SceneField fieldName, UnsignedLong object) const;
/** /**
* @brief Field flags * @brief Field flags
@ -2510,7 +2510,7 @@ class MAGNUM_TRADE_EXPORT SceneData {
* The @p object is expected to be less than @ref mappingBound(). * The @p object is expected to be less than @ref mappingBound().
* @see @ref childrenFor() * @see @ref childrenFor()
*/ */
Containers::Optional<Int> parentFor(UnsignedInt object) const; Containers::Optional<Long> parentFor(UnsignedLong object) const;
/** /**
* @brief Children for given object * @brief Children for given object
@ -2531,7 +2531,7 @@ class MAGNUM_TRADE_EXPORT SceneData {
* The @p object is expected to be less than @ref mappingBound(). * The @p object is expected to be less than @ref mappingBound().
* @see @ref parentFor() * @see @ref parentFor()
*/ */
Containers::Array<UnsignedInt> childrenFor(Int object) const; Containers::Array<UnsignedLong> childrenFor(Long object) const;
/** /**
* @brief 2D transformation for given object * @brief 2D transformation for given object
@ -2557,7 +2557,7 @@ class MAGNUM_TRADE_EXPORT SceneData {
* The @p object is expected to be less than @ref mappingBound(). * The @p object is expected to be less than @ref mappingBound().
* @see @ref translationRotationScaling2DFor() * @see @ref translationRotationScaling2DFor()
*/ */
Containers::Optional<Matrix3> transformation2DFor(UnsignedInt object) const; Containers::Optional<Matrix3> transformation2DFor(UnsignedLong object) const;
/** /**
* @brief 2D translation, rotation and scaling for given object * @brief 2D translation, rotation and scaling for given object
@ -2586,7 +2586,7 @@ class MAGNUM_TRADE_EXPORT SceneData {
* The @p object is expected to be less than @ref mappingBound(). * The @p object is expected to be less than @ref mappingBound().
* @see @ref transformation2DFor() * @see @ref transformation2DFor()
*/ */
Containers::Optional<Containers::Triple<Vector2, Complex, Vector2>> translationRotationScaling2DFor(UnsignedInt object) const; Containers::Optional<Containers::Triple<Vector2, Complex, Vector2>> translationRotationScaling2DFor(UnsignedLong object) const;
/** /**
* @brief 3D transformation for given object * @brief 3D transformation for given object
@ -2612,7 +2612,7 @@ class MAGNUM_TRADE_EXPORT SceneData {
* The @p object is expected to be less than @ref mappingBound(). * The @p object is expected to be less than @ref mappingBound().
* @see @ref translationRotationScaling3DFor() * @see @ref translationRotationScaling3DFor()
*/ */
Containers::Optional<Matrix4> transformation3DFor(UnsignedInt object) const; Containers::Optional<Matrix4> transformation3DFor(UnsignedLong object) const;
/** /**
* @brief 3D translation, rotation and scaling for given object * @brief 3D translation, rotation and scaling for given object
@ -2641,7 +2641,7 @@ class MAGNUM_TRADE_EXPORT SceneData {
* The @p object is expected to be less than @ref mappingBound(). * The @p object is expected to be less than @ref mappingBound().
* @see @ref transformation3DFor() * @see @ref transformation3DFor()
*/ */
Containers::Optional<Containers::Triple<Vector3, Quaternion, Vector3>> translationRotationScaling3DFor(UnsignedInt object) const; Containers::Optional<Containers::Triple<Vector3, Quaternion, Vector3>> translationRotationScaling3DFor(UnsignedLong object) const;
/** /**
* @brief Meshes and materials for given object * @brief Meshes and materials for given object
@ -2663,7 +2663,7 @@ class MAGNUM_TRADE_EXPORT SceneData {
* *
* The @p object is expected to be less than @ref mappingBound(). * The @p object is expected to be less than @ref mappingBound().
*/ */
Containers::Array<Containers::Pair<UnsignedInt, Int>> meshesMaterialsFor(UnsignedInt object) const; Containers::Array<Containers::Pair<UnsignedInt, Int>> meshesMaterialsFor(UnsignedLong object) const;
/** /**
* @brief Lights for given object * @brief Lights for given object
@ -2681,7 +2681,7 @@ class MAGNUM_TRADE_EXPORT SceneData {
* *
* The @p object is expected to be less than @ref mappingBound(). * The @p object is expected to be less than @ref mappingBound().
*/ */
Containers::Array<UnsignedInt> lightsFor(UnsignedInt object) const; Containers::Array<UnsignedInt> lightsFor(UnsignedLong object) const;
/** /**
* @brief Cameras for given object * @brief Cameras for given object
@ -2700,7 +2700,7 @@ class MAGNUM_TRADE_EXPORT SceneData {
* *
* The @p object is expected to be less than @ref mappingBound(). * The @p object is expected to be less than @ref mappingBound().
*/ */
Containers::Array<UnsignedInt> camerasFor(UnsignedInt object) const; Containers::Array<UnsignedInt> camerasFor(UnsignedLong object) const;
/** /**
* @brief Skins for given object * @brief Skins for given object
@ -2718,7 +2718,7 @@ class MAGNUM_TRADE_EXPORT SceneData {
* *
* The @p object is expected to be less than @ref mappingBound(). * The @p object is expected to be less than @ref mappingBound().
*/ */
Containers::Array<UnsignedInt> skinsFor(UnsignedInt object) const; Containers::Array<UnsignedInt> skinsFor(UnsignedLong object) const;
/** /**
* @brief Importer state for given object * @brief Importer state for given object
@ -2738,7 +2738,7 @@ class MAGNUM_TRADE_EXPORT SceneData {
* *
* The @p object is expected to be less than @ref mappingBound(). * The @p object is expected to be less than @ref mappingBound().
*/ */
Containers::Optional<const void*> importerStateFor(UnsignedInt object) const; Containers::Optional<const void*> importerStateFor(UnsignedLong object) const;
#ifdef MAGNUM_BUILD_DEPRECATED #ifdef MAGNUM_BUILD_DEPRECATED
/** /**
@ -2815,7 +2815,7 @@ class MAGNUM_TRADE_EXPORT SceneData {
/* Returns the offset at which `object` is for field at index `id`, or /* Returns the offset at which `object` is for field at index `id`, or
the end offset if the object is not found. The returned offset can the end offset if the object is not found. The returned offset can
be then passed to fieldData{Mapping,Field}ViewInternal(). */ be then passed to fieldData{Mapping,Field}ViewInternal(). */
MAGNUM_TRADE_LOCAL std::size_t findFieldObjectOffsetInternal(const SceneFieldData& field, UnsignedInt object, std::size_t offset) const; MAGNUM_TRADE_LOCAL std::size_t findFieldObjectOffsetInternal(const SceneFieldData& field, UnsignedLong object, std::size_t offset) const;
/* Like objects() / field(), but returning just a 1D view, sliced from /* Like objects() / field(), but returning just a 1D view, sliced from
offset to offset + size. The parameterless overloads are equal to offset to offset + size. The parameterless overloads are equal to

18
src/Magnum/Trade/Test/SceneDataTest.cpp

@ -4985,25 +4985,25 @@ void SceneDataTest::childrenFor() {
/* Just one child */ /* Just one child */
CORRADE_COMPARE_AS(scene.childrenFor(3), CORRADE_COMPARE_AS(scene.childrenFor(3),
Containers::arrayView<UnsignedInt>({2}), Containers::arrayView<UnsignedLong>({2}),
TestSuite::Compare::Container); TestSuite::Compare::Container);
/* More */ /* More */
CORRADE_COMPARE_AS(scene.childrenFor(-1), CORRADE_COMPARE_AS(scene.childrenFor(-1),
Containers::arrayView<UnsignedInt>({4, 0}), Containers::arrayView<UnsignedLong>({4, 0}),
TestSuite::Compare::Container); TestSuite::Compare::Container);
CORRADE_COMPARE_AS(scene.childrenFor(4), CORRADE_COMPARE_AS(scene.childrenFor(4),
Containers::arrayView<UnsignedInt>({3, 1, 5}), Containers::arrayView<UnsignedLong>({3, 1, 5}),
TestSuite::Compare::Container); TestSuite::Compare::Container);
/* Object that is present in the parent array but has no children */ /* Object that is present in the parent array but has no children */
CORRADE_COMPARE_AS(scene.childrenFor(5), CORRADE_COMPARE_AS(scene.childrenFor(5),
Containers::arrayView<UnsignedInt>({}), Containers::arrayView<UnsignedLong>({}),
TestSuite::Compare::Container); TestSuite::Compare::Container);
/* Object that is not in the parent array at all */ /* Object that is not in the parent array at all */
CORRADE_COMPARE_AS(scene.childrenFor(6), CORRADE_COMPARE_AS(scene.childrenFor(6),
Containers::arrayView<UnsignedInt>({}), Containers::arrayView<UnsignedLong>({}),
TestSuite::Compare::Container); TestSuite::Compare::Container);
} }
@ -5024,17 +5024,17 @@ void SceneDataTest::childrenForTrivialParent() {
/* Trivial children */ /* Trivial children */
CORRADE_COMPARE_AS(scene.childrenFor(-1), CORRADE_COMPARE_AS(scene.childrenFor(-1),
Containers::arrayView<UnsignedInt>({3, 4, 2, 4}), Containers::arrayView<UnsignedLong>({3, 4, 2, 4}),
TestSuite::Compare::Container); TestSuite::Compare::Container);
/* Object that is present in the parent array but has no children */ /* Object that is present in the parent array but has no children */
CORRADE_COMPARE_AS(scene.childrenFor(4), CORRADE_COMPARE_AS(scene.childrenFor(4),
Containers::arrayView<UnsignedInt>({}), Containers::arrayView<UnsignedLong>({}),
TestSuite::Compare::Container); TestSuite::Compare::Container);
/* Object that is not in the parent array */ /* Object that is not in the parent array */
CORRADE_COMPARE_AS(scene.childrenFor(5), CORRADE_COMPARE_AS(scene.childrenFor(5),
Containers::arrayView<UnsignedInt>({}), Containers::arrayView<UnsignedLong>({}),
TestSuite::Compare::Container); TestSuite::Compare::Container);
} }
@ -5461,7 +5461,7 @@ void SceneDataTest::fieldForFieldMissing() {
CORRADE_COMPARE(scene.parentFor(6), Containers::NullOpt); CORRADE_COMPARE(scene.parentFor(6), Containers::NullOpt);
CORRADE_COMPARE_AS(scene.childrenFor(6), CORRADE_COMPARE_AS(scene.childrenFor(6),
Containers::arrayView<UnsignedInt>({}), Containers::arrayView<UnsignedLong>({}),
TestSuite::Compare::Container); TestSuite::Compare::Container);
CORRADE_COMPARE(scene.transformation2DFor(6), Containers::NullOpt); CORRADE_COMPARE(scene.transformation2DFor(6), Containers::NullOpt);
CORRADE_COMPARE(scene.translationRotationScaling2DFor(6), Containers::NullOpt); CORRADE_COMPARE(scene.translationRotationScaling2DFor(6), Containers::NullOpt);

10
src/Magnum/Trade/Test/SceneToolsTest.cpp

@ -427,7 +427,7 @@ void SceneToolsTest::convertToSingleFunctionObjects() {
/* Object 0 should have new children with "foo", as it has a light */ /* Object 0 should have new children with "foo", as it has a light */
CORRADE_COMPARE_AS(scene.childrenFor(0), CORRADE_COMPARE_AS(scene.childrenFor(0),
Containers::arrayView<UnsignedInt>({67}), Containers::arrayView<UnsignedLong>({67}),
TestSuite::Compare::Container); TestSuite::Compare::Container);
CORRADE_COMPARE_AS(scene.lightsFor(0), CORRADE_COMPARE_AS(scene.lightsFor(0),
Containers::arrayView<UnsignedInt>({15}), Containers::arrayView<UnsignedInt>({15}),
@ -435,7 +435,7 @@ void SceneToolsTest::convertToSingleFunctionObjects() {
/* Object 1 should have a new child with "foo", as it has a light */ /* Object 1 should have a new child with "foo", as it has a light */
CORRADE_COMPARE_AS(scene.childrenFor(1), CORRADE_COMPARE_AS(scene.childrenFor(1),
Containers::arrayView<UnsignedInt>({68}), Containers::arrayView<UnsignedLong>({68}),
TestSuite::Compare::Container); TestSuite::Compare::Container);
CORRADE_COMPARE_AS(scene.lightsFor(1), CORRADE_COMPARE_AS(scene.lightsFor(1),
Containers::arrayView<UnsignedInt>({23}), Containers::arrayView<UnsignedInt>({23}),
@ -444,7 +444,7 @@ void SceneToolsTest::convertToSingleFunctionObjects() {
/* Object 2 should have a new child with the camera and "foo", as it has a /* Object 2 should have a new child with the camera and "foo", as it has a
mesh */ mesh */
CORRADE_COMPARE_AS(scene.childrenFor(2), CORRADE_COMPARE_AS(scene.childrenFor(2),
Containers::arrayView<UnsignedInt>({66, 69}), Containers::arrayView<UnsignedLong>({66, 69}),
TestSuite::Compare::Container); TestSuite::Compare::Container);
CORRADE_COMPARE_AS(scene.meshesMaterialsFor(2), CORRADE_COMPARE_AS(scene.meshesMaterialsFor(2),
(Containers::arrayView<Containers::Pair<UnsignedInt, Int>>({{7, 2}})), (Containers::arrayView<Containers::Pair<UnsignedInt, Int>>({{7, 2}})),
@ -458,7 +458,7 @@ void SceneToolsTest::convertToSingleFunctionObjects() {
/* Object 15 should have a new child that has the second mesh */ /* Object 15 should have a new child that has the second mesh */
CORRADE_COMPARE_AS(scene.childrenFor(15), CORRADE_COMPARE_AS(scene.childrenFor(15),
Containers::arrayView<UnsignedInt>({65}), Containers::arrayView<UnsignedLong>({65}),
TestSuite::Compare::Container); TestSuite::Compare::Container);
CORRADE_COMPARE_AS(scene.meshesMaterialsFor(15), CORRADE_COMPARE_AS(scene.meshesMaterialsFor(15),
(Containers::arrayView<Containers::Pair<UnsignedInt, Int>>({{6, 4}})), (Containers::arrayView<Containers::Pair<UnsignedInt, Int>>({{6, 4}})),
@ -470,7 +470,7 @@ void SceneToolsTest::convertToSingleFunctionObjects() {
/* Object 23 should have two new children that have the second and third /* Object 23 should have two new children that have the second and third
mesh */ mesh */
CORRADE_COMPARE_AS(scene.childrenFor(23), CORRADE_COMPARE_AS(scene.childrenFor(23),
Containers::arrayView<UnsignedInt>({63, 64}), Containers::arrayView<UnsignedLong>({63, 64}),
TestSuite::Compare::Container); TestSuite::Compare::Container);
CORRADE_COMPARE_AS(scene.meshesMaterialsFor(23), CORRADE_COMPARE_AS(scene.meshesMaterialsFor(23),
(Containers::arrayView<Containers::Pair<UnsignedInt, Int>>({{1, 0}})), (Containers::arrayView<Containers::Pair<UnsignedInt, Int>>({{1, 0}})),

Loading…
Cancel
Save