Updated ozz-animation to version 0.14.1 @35b2efd4
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
//----------------------------------------------------------------------------//
|
||||
// //
|
||||
// ozz-animation is hosted at http://github.com/guillaumeblanc/ozz-animation //
|
||||
// and distributed under the MIT License (MIT). //
|
||||
// //
|
||||
// Copyright (c) Guillaume Blanc //
|
||||
// //
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a //
|
||||
// copy of this software and associated documentation files (the "Software"), //
|
||||
// to deal in the Software without restriction, including without limitation //
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense, //
|
||||
// and/or sell copies of the Software, and to permit persons to whom the //
|
||||
// Software is furnished to do so, subject to the following conditions: //
|
||||
// //
|
||||
// The above copyright notice and this permission notice shall be included in //
|
||||
// all copies or substantial portions of the Software. //
|
||||
// //
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR //
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, //
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL //
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER //
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING //
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER //
|
||||
// DEALINGS IN THE SOFTWARE. //
|
||||
// //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#ifndef OZZ_OZZ_BASE_CONTAINERS_ARRAY_H_
|
||||
#define OZZ_OZZ_BASE_CONTAINERS_ARRAY_H_
|
||||
|
||||
#include <array>
|
||||
|
||||
#include "ozz/base/platform.h"
|
||||
|
||||
namespace ozz {
|
||||
// Redirects std::array to ozz::array .
|
||||
template <class _Ty, size_t _N>
|
||||
using array = std::array<_Ty, _N>;
|
||||
|
||||
// Extends std::array with two functions that gives access to the begin and the
|
||||
// end of its array of elements.
|
||||
|
||||
// Returns the mutable begin of the array of elements, or nullptr if
|
||||
// array's empty.
|
||||
template <class _Ty, size_t _N>
|
||||
inline _Ty* array_begin(std::array<_Ty, _N>& _array) {
|
||||
return _array.data();
|
||||
}
|
||||
|
||||
// Returns the non-mutable begin of the array of elements, or nullptr if
|
||||
// array's empty.
|
||||
template <class _Ty, size_t _N>
|
||||
inline const _Ty* array_begin(const std::array<_Ty, _N>& _array) {
|
||||
return _array.data();
|
||||
}
|
||||
|
||||
// Returns the mutable end of the array of elements, or nullptr if
|
||||
// array's empty. Array end is one element past the last element of the
|
||||
// array, it cannot be dereferenced.
|
||||
template <class _Ty, size_t _N>
|
||||
inline _Ty* array_end(std::array<_Ty, _N>& _array) {
|
||||
return _array.data() + _N;
|
||||
}
|
||||
|
||||
// Returns the non-mutable end of the array of elements, or nullptr if
|
||||
// array's empty. Array end is one element past the last element of the
|
||||
// array, it cannot be dereferenced.
|
||||
template <class _Ty, size_t _N>
|
||||
inline const _Ty* array_end(const std::array<_Ty, _N>& _array) {
|
||||
return _array.data() + _N;
|
||||
}
|
||||
} // namespace ozz
|
||||
#endif // OZZ_OZZ_BASE_CONTAINERS_ARRAY_H_
|
||||
@@ -0,0 +1,63 @@
|
||||
//----------------------------------------------------------------------------//
|
||||
// //
|
||||
// ozz-animation is hosted at http://github.com/guillaumeblanc/ozz-animation //
|
||||
// and distributed under the MIT License (MIT). //
|
||||
// //
|
||||
// Copyright (c) Guillaume Blanc //
|
||||
// //
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a //
|
||||
// copy of this software and associated documentation files (the "Software"), //
|
||||
// to deal in the Software without restriction, including without limitation //
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense, //
|
||||
// and/or sell copies of the Software, and to permit persons to whom the //
|
||||
// Software is furnished to do so, subject to the following conditions: //
|
||||
// //
|
||||
// The above copyright notice and this permission notice shall be included in //
|
||||
// all copies or substantial portions of the Software. //
|
||||
// //
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR //
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, //
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL //
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER //
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING //
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER //
|
||||
// DEALINGS IN THE SOFTWARE. //
|
||||
// //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#ifndef OZZ_OZZ_BASE_CONTAINERS_ARRAY_ARCHIVE_H_
|
||||
#define OZZ_OZZ_BASE_CONTAINERS_ARRAY_ARCHIVE_H_
|
||||
|
||||
#include "ozz/base/containers/array.h"
|
||||
#include "ozz/base/io/archive.h"
|
||||
|
||||
namespace ozz {
|
||||
namespace io {
|
||||
|
||||
OZZ_IO_TYPE_NOT_VERSIONABLE_T2(class _Ty, size_t _N, std::array<_Ty, _N>)
|
||||
|
||||
template <class _Ty, size_t _N>
|
||||
struct Extern<std::array<_Ty, _N>> {
|
||||
inline static void Save(OArchive& _archive,
|
||||
const std::array<_Ty, _N>* _values, size_t _count) {
|
||||
if (void(0), _N != 0) {
|
||||
for (size_t i = 0; i < _count; i++) {
|
||||
const std::array<_Ty, _N>& array = _values[i];
|
||||
_archive << ozz::io::MakeArray(array.data(), _N);
|
||||
}
|
||||
}
|
||||
}
|
||||
inline static void Load(IArchive& _archive, std::array<_Ty, _N>* _values,
|
||||
size_t _count, uint32_t _version) {
|
||||
(void)_version;
|
||||
if (void(0), _N != 0) {
|
||||
for (size_t i = 0; i < _count; i++) {
|
||||
std::array<_Ty, _N>& array = _values[i];
|
||||
_archive >> ozz::io::MakeArray(array.data(), _N);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
} // namespace io
|
||||
} // namespace ozz
|
||||
#endif // OZZ_OZZ_BASE_CONTAINERS_ARRAY_ARCHIVE_H_
|
||||
@@ -49,7 +49,7 @@ class StdAllocator {
|
||||
StdAllocator(const StdAllocator&) noexcept {}
|
||||
|
||||
template <class _Other>
|
||||
StdAllocator<value_type>(const StdAllocator<_Other>&) noexcept {}
|
||||
StdAllocator(const StdAllocator<_Other>&) noexcept {}
|
||||
|
||||
template <class _Other>
|
||||
struct rebind {
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace io {
|
||||
OZZ_IO_TYPE_NOT_VERSIONABLE(ozz::string)
|
||||
|
||||
template <>
|
||||
struct Extern<ozz::string> {
|
||||
struct OZZ_BASE_DLL Extern<ozz::string> {
|
||||
static void Save(OArchive& _archive, const ozz::string* _values,
|
||||
size_t _count);
|
||||
static void Load(IArchive& _archive, ozz::string* _values, size_t _count,
|
||||
|
||||
@@ -48,7 +48,7 @@ struct Extern<std::vector<_Ty, _Allocator>> {
|
||||
const uint32_t size = static_cast<uint32_t>(vector.size());
|
||||
_archive << size;
|
||||
if (size > 0) {
|
||||
_archive << ozz::io::MakeArray(&vector[0], size);
|
||||
_archive << ozz::io::MakeArray(vector.data(), size);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ struct Extern<std::vector<_Ty, _Allocator>> {
|
||||
_archive >> size;
|
||||
vector.resize(size);
|
||||
if (size > 0) {
|
||||
_archive >> ozz::io::MakeArray(&vector[0], size);
|
||||
_archive >> ozz::io::MakeArray(vector.data(), size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-15
@@ -66,20 +66,17 @@ template <typename _Ty, size_t _size = sizeof(_Ty)>
|
||||
struct EndianSwapper;
|
||||
|
||||
// Internal macro used to swap two bytes.
|
||||
#define OZZ_BYTE_SWAP(_a, _b) \
|
||||
do { \
|
||||
const char temp = _a; \
|
||||
_a = _b; \
|
||||
_b = temp; \
|
||||
#define OZZ_BYTE_SWAP(_a, _b) \
|
||||
do { \
|
||||
const ozz::byte temp = (_a); \
|
||||
(_a) = (_b); \
|
||||
(_b) = temp; \
|
||||
} while (0)
|
||||
|
||||
// EndianSwapper specialization for 1 byte types.
|
||||
template <typename _Ty>
|
||||
struct EndianSwapper<_Ty, 1> {
|
||||
OZZ_INLINE static void Swap(_Ty* _ty, size_t _count) {
|
||||
(void)_ty;
|
||||
(void)_count;
|
||||
}
|
||||
OZZ_INLINE static void Swap(_Ty*, size_t) {}
|
||||
OZZ_INLINE static _Ty Swap(_Ty _ty) { return _ty; }
|
||||
};
|
||||
|
||||
@@ -87,13 +84,13 @@ struct EndianSwapper<_Ty, 1> {
|
||||
template <typename _Ty>
|
||||
struct EndianSwapper<_Ty, 2> {
|
||||
OZZ_INLINE static void Swap(_Ty* _ty, size_t _count) {
|
||||
char* alias = reinterpret_cast<char*>(_ty);
|
||||
byte* alias = reinterpret_cast<byte*>(_ty);
|
||||
for (size_t i = 0; i < _count * 2; i += 2) {
|
||||
OZZ_BYTE_SWAP(alias[i + 0], alias[i + 1]);
|
||||
}
|
||||
}
|
||||
OZZ_INLINE static _Ty Swap(_Ty _ty) { // Pass by copy to swap _ty in-place.
|
||||
char* alias = reinterpret_cast<char*>(&_ty);
|
||||
byte* alias = reinterpret_cast<byte*>(&_ty);
|
||||
OZZ_BYTE_SWAP(alias[0], alias[1]);
|
||||
return _ty;
|
||||
}
|
||||
@@ -103,14 +100,14 @@ struct EndianSwapper<_Ty, 2> {
|
||||
template <typename _Ty>
|
||||
struct EndianSwapper<_Ty, 4> {
|
||||
OZZ_INLINE static void Swap(_Ty* _ty, size_t _count) {
|
||||
char* alias = reinterpret_cast<char*>(_ty);
|
||||
byte* alias = reinterpret_cast<byte*>(_ty);
|
||||
for (size_t i = 0; i < _count * 4; i += 4) {
|
||||
OZZ_BYTE_SWAP(alias[i + 0], alias[i + 3]);
|
||||
OZZ_BYTE_SWAP(alias[i + 1], alias[i + 2]);
|
||||
}
|
||||
}
|
||||
OZZ_INLINE static _Ty Swap(_Ty _ty) { // Pass by copy to swap _ty in-place.
|
||||
char* alias = reinterpret_cast<char*>(&_ty);
|
||||
byte* alias = reinterpret_cast<byte*>(&_ty);
|
||||
OZZ_BYTE_SWAP(alias[0], alias[3]);
|
||||
OZZ_BYTE_SWAP(alias[1], alias[2]);
|
||||
return _ty;
|
||||
@@ -121,7 +118,7 @@ struct EndianSwapper<_Ty, 4> {
|
||||
template <typename _Ty>
|
||||
struct EndianSwapper<_Ty, 8> {
|
||||
OZZ_INLINE static void Swap(_Ty* _ty, size_t _count) {
|
||||
char* alias = reinterpret_cast<char*>(_ty);
|
||||
byte* alias = reinterpret_cast<byte*>(_ty);
|
||||
for (size_t i = 0; i < _count * 8; i += 8) {
|
||||
OZZ_BYTE_SWAP(alias[i + 0], alias[i + 7]);
|
||||
OZZ_BYTE_SWAP(alias[i + 1], alias[i + 6]);
|
||||
@@ -130,7 +127,7 @@ struct EndianSwapper<_Ty, 8> {
|
||||
}
|
||||
}
|
||||
OZZ_INLINE static _Ty Swap(_Ty _ty) { // Pass by copy to swap _ty in-place.
|
||||
char* alias = reinterpret_cast<char*>(&_ty);
|
||||
byte* alias = reinterpret_cast<byte*>(&_ty);
|
||||
OZZ_BYTE_SWAP(alias[0], alias[7]);
|
||||
OZZ_BYTE_SWAP(alias[1], alias[6]);
|
||||
OZZ_BYTE_SWAP(alias[2], alias[5]);
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
//----------------------------------------------------------------------------//
|
||||
// //
|
||||
// ozz-animation is hosted at http://github.com/guillaumeblanc/ozz-animation //
|
||||
// and distributed under the MIT License (MIT). //
|
||||
// //
|
||||
// Copyright (c) Guillaume Blanc //
|
||||
// //
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a //
|
||||
// copy of this software and associated documentation files (the "Software"), //
|
||||
// to deal in the Software without restriction, including without limitation //
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense, //
|
||||
// and/or sell copies of the Software, and to permit persons to whom the //
|
||||
// Software is furnished to do so, subject to the following conditions: //
|
||||
// //
|
||||
// The above copyright notice and this permission notice shall be included in //
|
||||
// all copies or substantial portions of the Software. //
|
||||
// //
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR //
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, //
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL //
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER //
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING //
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER //
|
||||
// DEALINGS IN THE SOFTWARE. //
|
||||
// //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#ifndef OZZ_OZZ_BASE_EXPORT_H_
|
||||
#define OZZ_OZZ_BASE_EXPORT_H_
|
||||
|
||||
#if defined(_MSC_VER) && defined(OZZ_USE_DYNAMIC_LINKING)
|
||||
|
||||
#ifdef OZZ_BUILD_BASE_LIB
|
||||
// Import/Export for dynamic linking while building ozz
|
||||
#define OZZ_BASE_DLL __declspec(dllexport)
|
||||
#else
|
||||
#define OZZ_BASE_DLL __declspec(dllimport)
|
||||
#endif
|
||||
#else // defined(_MSC_VER) && defined(OZZ_USE_DYNAMIC_LINKING)
|
||||
// Static or non msvc linking
|
||||
#define OZZ_BASE_DLL
|
||||
#endif // defined(_MSC_VER) && defined(OZZ_USE_DYNAMIC_LINKING)
|
||||
|
||||
#endif // OZZ_OZZ_BASE_EXPORT_H_
|
||||
+10
-10
@@ -77,16 +77,16 @@
|
||||
// integrity, like data corruption or file truncation, must also be validated on
|
||||
// the user side.
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "ozz/base/endianness.h"
|
||||
#include "ozz/base/io/archive_traits.h"
|
||||
#include "ozz/base/io/stream.h"
|
||||
#include "ozz/base/platform.h"
|
||||
#include "ozz/base/span.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <cassert>
|
||||
|
||||
#include "ozz/base/io/archive_traits.h"
|
||||
|
||||
namespace ozz {
|
||||
namespace io {
|
||||
namespace internal {
|
||||
@@ -102,7 +102,7 @@ struct Tagger;
|
||||
// The output endianness mode is set at construction time. It is written to the
|
||||
// stream to allow the IArchive to perform the required conversion to the native
|
||||
// endianness mode while reading.
|
||||
class OArchive {
|
||||
class OZZ_BASE_DLL OArchive {
|
||||
public:
|
||||
// Constructs an output archive from the Stream _stream that must be valid
|
||||
// and opened for writing.
|
||||
@@ -126,7 +126,7 @@ class OArchive {
|
||||
}
|
||||
|
||||
// Primitive type saving.
|
||||
#define OZZ_IO_PRIMITIVE_TYPE(_type) \
|
||||
#define OZZ_IO_PRIMITIVE_TYPE(_type) \
|
||||
void operator<<(_type _v) { \
|
||||
_type v = endian_swap_ ? EndianSwapper<_type>::Swap(_v) : _v; \
|
||||
OZZ_IF_DEBUG(size_t size =) stream_->Write(&v, sizeof(v)); \
|
||||
@@ -171,7 +171,7 @@ class OArchive {
|
||||
// Implements input archive concept used to load/de-serialize data to a Stream.
|
||||
// Endianness conversions are automatically performed according to the Archive
|
||||
// and the native formats.
|
||||
class IArchive {
|
||||
class OZZ_BASE_DLL IArchive {
|
||||
public:
|
||||
// Constructs an input archive from the Stream _stream that must be opened for
|
||||
// reading, at the same tell (position in the stream) as when it was passed to
|
||||
@@ -199,7 +199,7 @@ class IArchive {
|
||||
}
|
||||
|
||||
// Primitive type loading.
|
||||
#define OZZ_IO_PRIMITIVE_TYPE(_type) \
|
||||
#define OZZ_IO_PRIMITIVE_TYPE(_type) \
|
||||
void operator>>(_type& _v) { \
|
||||
_type v; \
|
||||
OZZ_IF_DEBUG(size_t size =) stream_->Read(&v, sizeof(v)); \
|
||||
@@ -314,7 +314,7 @@ struct Version<const Array<_Ty>> {
|
||||
};
|
||||
|
||||
// Specializes Array Save/Load for primitive types.
|
||||
#define OZZ_IO_PRIMITIVE_TYPE(_type) \
|
||||
#define OZZ_IO_PRIMITIVE_TYPE(_type) \
|
||||
template <> \
|
||||
inline void Array<const _type>::Save(OArchive& _archive) const { \
|
||||
if (_archive.endian_swap()) { \
|
||||
|
||||
+6
-6
@@ -31,16 +31,16 @@
|
||||
// Provides Stream interface used to read/write a memory buffer or a file with
|
||||
// Crt fread/fwrite/fseek/ftell like functions.
|
||||
|
||||
#include "ozz/base/platform.h"
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include "ozz/base/platform.h"
|
||||
|
||||
namespace ozz {
|
||||
namespace io {
|
||||
|
||||
// Declares a stream access interface that conforms with CRT FILE API.
|
||||
// This interface should be used to remap io operations.
|
||||
class Stream {
|
||||
class OZZ_BASE_DLL Stream {
|
||||
public:
|
||||
// Tests whether a file is opened.
|
||||
virtual bool opened() const = 0;
|
||||
@@ -86,7 +86,7 @@ class Stream {
|
||||
};
|
||||
|
||||
// Implements Stream of type File.
|
||||
class File : public Stream {
|
||||
class OZZ_BASE_DLL File : public Stream {
|
||||
public:
|
||||
// Test if a file at path _filename exists.
|
||||
// Note that this function is costly. If you aim to open the file right after,
|
||||
@@ -133,7 +133,7 @@ class File : public Stream {
|
||||
|
||||
// Implements an in-memory Stream. Allows to use a memory buffer as a Stream.
|
||||
// The opening mode is equivalent to fopen w+b (binary read/write).
|
||||
class MemoryStream : public Stream {
|
||||
class OZZ_BASE_DLL MemoryStream : public Stream {
|
||||
public:
|
||||
// Construct an empty memory stream opened in w+b mode.
|
||||
MemoryStream();
|
||||
@@ -172,7 +172,7 @@ class MemoryStream : public Stream {
|
||||
static const size_t kMaxSize;
|
||||
|
||||
// Buffer of data.
|
||||
char* buffer_;
|
||||
byte* buffer_;
|
||||
|
||||
// The size of the buffer, which is greater or equal to the size of the data
|
||||
// it contains (end_).
|
||||
|
||||
+10
-8
@@ -34,6 +34,8 @@
|
||||
// So it is included here to ensure a portable behavior.
|
||||
#include <cstring>
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
// Proposes a logging interface that redirects logs to std::cout, clog and cerr
|
||||
// output streams. This interface adds a logging level functionality (kSilent,
|
||||
// kStandard, kVerbose) to the std API, which can be set using
|
||||
@@ -50,17 +52,17 @@ enum Level {
|
||||
};
|
||||
|
||||
// Sets the global logging level.
|
||||
Level SetLevel(Level _level);
|
||||
OZZ_BASE_DLL Level SetLevel(Level _level);
|
||||
|
||||
// Gets the global logging level.
|
||||
Level GetLevel();
|
||||
OZZ_BASE_DLL Level GetLevel();
|
||||
|
||||
// Implements logging base class.
|
||||
// This class is not intended to be used publicly, it is derived by user
|
||||
// classes LogV, Log, Out, Err...
|
||||
// Forwards ostream::operator << to a standard ostream or a silent
|
||||
// ostringstream according to the logging level at construction time.
|
||||
class Logger {
|
||||
class OZZ_BASE_DLL Logger {
|
||||
public:
|
||||
// Forwards ostream::operator << for any type.
|
||||
template <typename _T>
|
||||
@@ -101,28 +103,28 @@ class Logger {
|
||||
|
||||
// Logs verbose output to the standard error stream (std::clog).
|
||||
// Enabled if logging level is Verbose.
|
||||
class LogV : public Logger {
|
||||
class OZZ_BASE_DLL LogV : public Logger {
|
||||
public:
|
||||
LogV();
|
||||
};
|
||||
|
||||
// Logs output to the standard error stream (std::clog).
|
||||
// Enabled if logging level is not Silent.
|
||||
class Log : public Logger {
|
||||
class OZZ_BASE_DLL Log : public Logger {
|
||||
public:
|
||||
Log();
|
||||
};
|
||||
|
||||
// Logs output to the standard output (std::cout).
|
||||
// Enabled if logging level is not Silent.
|
||||
class Out : public Logger {
|
||||
class OZZ_BASE_DLL Out : public Logger {
|
||||
public:
|
||||
Out();
|
||||
};
|
||||
|
||||
// Logs error to the standard error stream (std::cerr).
|
||||
// Enabled if logging level is not Silent.
|
||||
class Err : public Logger {
|
||||
class OZZ_BASE_DLL Err : public Logger {
|
||||
public:
|
||||
Err();
|
||||
};
|
||||
@@ -131,7 +133,7 @@ class Err : public Logger {
|
||||
// settings when exiting scope.
|
||||
// User is reponsible for making sure stream still exist upon RAII destruction.
|
||||
// See std::setprecision() for more details.
|
||||
class FloatPrecision {
|
||||
class OZZ_BASE_DLL FloatPrecision {
|
||||
public:
|
||||
FloatPrecision(const Logger& _logger, int _precision);
|
||||
~FloatPrecision();
|
||||
|
||||
+2
-2
@@ -39,7 +39,7 @@ namespace math {
|
||||
struct Float4x4;
|
||||
|
||||
// Defines an axis aligned box.
|
||||
struct Box {
|
||||
struct OZZ_BASE_DLL Box {
|
||||
// Constructs an invalid box.
|
||||
Box();
|
||||
|
||||
@@ -78,7 +78,7 @@ OZZ_INLINE Box Merge(const Box& _a, const Box& _b) {
|
||||
}
|
||||
|
||||
// Compute box transformation by a matrix.
|
||||
Box TransformBox(const Float4x4& _matrix, const Box& _box);
|
||||
OZZ_BASE_DLL Box TransformBox(const Float4x4& _matrix, const Box& _box);
|
||||
} // namespace math
|
||||
} // namespace ozz
|
||||
#endif // OZZ_OZZ_BASE_MATHS_BOX_H_
|
||||
|
||||
@@ -152,7 +152,8 @@ typedef const SimdInt4& _SimdInt4;
|
||||
} // namespace ozz
|
||||
#endif // OZZ_SIMD_x
|
||||
|
||||
// Native SIMD operator already exist on some compilers, so they have to be disable from ozz implementation
|
||||
// Native SIMD operator already exist on some compilers, so they have to be
|
||||
// disable from ozz implementation
|
||||
#if !defined(OZZ_SIMD_REF) && (defined(__GNUC__) || defined(__llvm__))
|
||||
#define OZZ_DISABLE_SSE_NATIVE_OPERATORS
|
||||
#endif
|
||||
|
||||
+4
-16
@@ -31,6 +31,7 @@
|
||||
// SIMD refence implementation, based on scalar floats.
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <cstddef>
|
||||
@@ -1820,22 +1821,9 @@ OZZ_INLINE bool ToAffine(const Float4x4& _m, SimdFloat4* _translation,
|
||||
}
|
||||
|
||||
OZZ_INLINE Float4x4 Float4x4::FromEuler(_SimdFloat4 _v) {
|
||||
const float ch = std::cos(_v.x);
|
||||
const float sh = std::sin(_v.x);
|
||||
const float ca = std::cos(_v.y);
|
||||
const float sa = std::sin(_v.y);
|
||||
const float cb = std::cos(_v.z);
|
||||
const float sb = std::sin(_v.z);
|
||||
|
||||
const float sa_cb = sa * cb;
|
||||
const float sa_sb = sa * sb;
|
||||
|
||||
const Float4x4 ret = {
|
||||
{{ch * ca, sh * sb - ch * sa_cb, ch * sa_sb + sh * cb, 0.f},
|
||||
{sa, ca * cb, -ca * sb, 0.f},
|
||||
{-sh * ca, sh * sa_cb + ch * sb, -sh * sa_sb + ch * cb, 0.f},
|
||||
{0.f, 0.f, 0.f, 1.f}}};
|
||||
return ret;
|
||||
return Float4x4::FromAxisAngle(simd_float4::y_axis(), SplatX(_v)) *
|
||||
Float4x4::FromAxisAngle(simd_float4::x_axis(), SplatY(_v)) *
|
||||
Float4x4::FromAxisAngle(simd_float4::z_axis(), SplatZ(_v));
|
||||
}
|
||||
|
||||
OZZ_INLINE Float4x4 Float4x4::FromAxisAngle(_SimdFloat4 _axis,
|
||||
|
||||
+6
-22
@@ -31,6 +31,7 @@
|
||||
// SIMD SSE2+ implementation, based on scalar floats.
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
// Temporarly needed while trigonometric functions aren't implemented.
|
||||
@@ -1294,7 +1295,7 @@ OZZ_INLINE SimdInt4 Sign(_SimdInt4 _v) {
|
||||
OZZ_INLINE SimdInt4 Min(_SimdInt4 _a, _SimdInt4 _b) {
|
||||
#ifdef OZZ_SIMD_SSE4_1
|
||||
return _mm_min_epi32(_a, _b);
|
||||
#else // OZZ_SIMD_SSE4_1
|
||||
#else // OZZ_SIMD_SSE4_1
|
||||
return OZZ_SSE_SELECT_I(_mm_cmplt_epi32(_a, _b), _a, _b);
|
||||
#endif // OZZ_SIMD_SSE4_1
|
||||
}
|
||||
@@ -1302,7 +1303,7 @@ OZZ_INLINE SimdInt4 Min(_SimdInt4 _a, _SimdInt4 _b) {
|
||||
OZZ_INLINE SimdInt4 Max(_SimdInt4 _a, _SimdInt4 _b) {
|
||||
#ifdef OZZ_SIMD_SSE4_1
|
||||
return _mm_max_epi32(_a, _b);
|
||||
#else // OZZ_SIMD_SSE4_1
|
||||
#else // OZZ_SIMD_SSE4_1
|
||||
return OZZ_SSE_SELECT_I(_mm_cmpgt_epi32(_a, _b), _a, _b);
|
||||
#endif // OZZ_SIMD_SSE4_1
|
||||
}
|
||||
@@ -1775,26 +1776,9 @@ inline bool ToAffine(const Float4x4& _m, SimdFloat4* _translation,
|
||||
}
|
||||
|
||||
inline Float4x4 Float4x4::FromEuler(_SimdFloat4 _v) {
|
||||
const __m128 cos = Cos(_v);
|
||||
const __m128 sin = Sin(_v);
|
||||
|
||||
const float cx = GetX(cos);
|
||||
const float sx = GetX(sin);
|
||||
const float cy = GetY(cos);
|
||||
const float sy = GetY(sin);
|
||||
const float cz = GetZ(cos);
|
||||
const float sz = GetZ(sin);
|
||||
|
||||
const float sycz = sy * cz;
|
||||
const float sysz = sy * sz;
|
||||
|
||||
const Float4x4 ret = {{simd_float4::Load(cx * cy, sx * sz - cx * sycz,
|
||||
cx * sysz + sx * cz, 0.f),
|
||||
simd_float4::Load(sy, cy * cz, -cy * sz, 0.f),
|
||||
simd_float4::Load(-sx * cy, sx * sycz + cx * sz,
|
||||
-sx * sysz + cx * cz, 0.f),
|
||||
simd_float4::w_axis()}};
|
||||
return ret;
|
||||
return Float4x4::FromAxisAngle(simd_float4::y_axis(), SplatX(_v)) *
|
||||
Float4x4::FromAxisAngle(simd_float4::x_axis(), SplatY(_v)) *
|
||||
Float4x4::FromAxisAngle(simd_float4::z_axis(), SplatZ(_v));
|
||||
}
|
||||
|
||||
inline Float4x4 Float4x4::FromAxisAngle(_SimdFloat4 _axis, _SimdFloat4 _angle) {
|
||||
|
||||
@@ -45,7 +45,7 @@ struct RectInt;
|
||||
namespace io {
|
||||
OZZ_IO_TYPE_NOT_VERSIONABLE(math::Float2)
|
||||
template <>
|
||||
struct Extern<math::Float2> {
|
||||
struct OZZ_BASE_DLL Extern<math::Float2> {
|
||||
static void Save(OArchive& _archive, const math::Float2* _values,
|
||||
size_t _count);
|
||||
static void Load(IArchive& _archive, math::Float2* _values, size_t _count,
|
||||
@@ -54,7 +54,7 @@ struct Extern<math::Float2> {
|
||||
|
||||
OZZ_IO_TYPE_NOT_VERSIONABLE(math::Float3)
|
||||
template <>
|
||||
struct Extern<math::Float3> {
|
||||
struct OZZ_BASE_DLL Extern<math::Float3> {
|
||||
static void Save(OArchive& _archive, const math::Float3* _values,
|
||||
size_t _count);
|
||||
static void Load(IArchive& _archive, math::Float3* _values, size_t _count,
|
||||
@@ -63,7 +63,7 @@ struct Extern<math::Float3> {
|
||||
|
||||
OZZ_IO_TYPE_NOT_VERSIONABLE(math::Float4)
|
||||
template <>
|
||||
struct Extern<math::Float4> {
|
||||
struct OZZ_BASE_DLL Extern<math::Float4> {
|
||||
static void Save(OArchive& _archive, const math::Float4* _values,
|
||||
size_t _count);
|
||||
static void Load(IArchive& _archive, math::Float4* _values, size_t _count,
|
||||
@@ -72,7 +72,7 @@ struct Extern<math::Float4> {
|
||||
|
||||
OZZ_IO_TYPE_NOT_VERSIONABLE(math::Quaternion)
|
||||
template <>
|
||||
struct Extern<math::Quaternion> {
|
||||
struct OZZ_BASE_DLL Extern<math::Quaternion> {
|
||||
static void Save(OArchive& _archive, const math::Quaternion* _values,
|
||||
size_t _count);
|
||||
static void Load(IArchive& _archive, math::Quaternion* _values, size_t _count,
|
||||
@@ -81,7 +81,7 @@ struct Extern<math::Quaternion> {
|
||||
|
||||
OZZ_IO_TYPE_NOT_VERSIONABLE(math::Transform)
|
||||
template <>
|
||||
struct Extern<math::Transform> {
|
||||
struct OZZ_BASE_DLL Extern<math::Transform> {
|
||||
static void Save(OArchive& _archive, const math::Transform* _values,
|
||||
size_t _count);
|
||||
static void Load(IArchive& _archive, math::Transform* _values, size_t _count,
|
||||
@@ -90,7 +90,7 @@ struct Extern<math::Transform> {
|
||||
|
||||
OZZ_IO_TYPE_NOT_VERSIONABLE(math::Box)
|
||||
template <>
|
||||
struct Extern<math::Box> {
|
||||
struct OZZ_BASE_DLL Extern<math::Box> {
|
||||
static void Save(OArchive& _archive, const math::Box* _values, size_t _count);
|
||||
static void Load(IArchive& _archive, math::Box* _values, size_t _count,
|
||||
uint32_t _version);
|
||||
@@ -98,7 +98,7 @@ struct Extern<math::Box> {
|
||||
|
||||
OZZ_IO_TYPE_NOT_VERSIONABLE(math::RectFloat)
|
||||
template <>
|
||||
struct Extern<math::RectFloat> {
|
||||
struct OZZ_BASE_DLL Extern<math::RectFloat> {
|
||||
static void Save(OArchive& _archive, const math::RectFloat* _values,
|
||||
size_t _count);
|
||||
static void Load(IArchive& _archive, math::RectFloat* _values, size_t _count,
|
||||
@@ -107,7 +107,7 @@ struct Extern<math::RectFloat> {
|
||||
|
||||
OZZ_IO_TYPE_NOT_VERSIONABLE(math::RectInt)
|
||||
template <>
|
||||
struct Extern<math::RectInt> {
|
||||
struct OZZ_BASE_DLL Extern<math::RectInt> {
|
||||
static void Save(OArchive& _archive, const math::RectInt* _values,
|
||||
size_t _count);
|
||||
static void Load(IArchive& _archive, math::RectInt* _values, size_t _count,
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
namespace ozz {
|
||||
namespace math {
|
||||
|
||||
struct Quaternion {
|
||||
struct OZZ_BASE_DLL Quaternion {
|
||||
float x, y, z, w;
|
||||
|
||||
// Constructs an uninitialized quaternion.
|
||||
|
||||
+4
-2
@@ -28,12 +28,14 @@
|
||||
#ifndef OZZ_OZZ_BASE_MATHS_RECT_H_
|
||||
#define OZZ_OZZ_BASE_MATHS_RECT_H_
|
||||
|
||||
#include "../platform.h"
|
||||
|
||||
namespace ozz {
|
||||
namespace math {
|
||||
|
||||
// Defines a rectangle by the integer coordinates of its lower-left and
|
||||
// width-height.
|
||||
struct RectInt {
|
||||
struct OZZ_BASE_DLL RectInt {
|
||||
// Constructs a uninitialized rectangle.
|
||||
RectInt() {}
|
||||
|
||||
@@ -65,7 +67,7 @@ struct RectInt {
|
||||
|
||||
// Defines a rectangle by the floating point coordinates of its lower-left
|
||||
// and width-height.
|
||||
struct RectFloat {
|
||||
struct OZZ_BASE_DLL RectFloat {
|
||||
// Constructs a uninitialized rectangle.
|
||||
RectFloat() {}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace ozz {
|
||||
namespace math {
|
||||
|
||||
// Returns SIMDimplementation name has decided at library build time.
|
||||
const char* SimdImplementationName();
|
||||
OZZ_BASE_DLL const char* SimdImplementationName();
|
||||
|
||||
namespace simd_float4 {
|
||||
// Returns a SimdFloat4 vector with all components set to 0.
|
||||
@@ -241,10 +241,6 @@ OZZ_INLINE void Transpose4x1(const SimdFloat4 _in[4], SimdFloat4 _out[1]);
|
||||
// Remaining y, z and w are set to 0.
|
||||
OZZ_INLINE void Transpose1x4(const SimdFloat4 _in[1], SimdFloat4 _out[4]);
|
||||
|
||||
// Transposes the 1 SimdFloat4 of _in into the x components of the 4
|
||||
// SimdFloat4 of _out. Remaining y, z and w are set to 0.
|
||||
OZZ_INLINE void Transpose2x4(const SimdFloat4 _in[2], SimdFloat4 _out[4]);
|
||||
|
||||
// Transposes the x and y components of the 4 SimdFloat4 of _in into the 2
|
||||
// SimdFloat4 of _out.
|
||||
OZZ_INLINE void Transpose4x2(const SimdFloat4 _in[4], SimdFloat4 _out[2]);
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace ozz {
|
||||
namespace io {
|
||||
OZZ_IO_TYPE_NOT_VERSIONABLE(math::SimdFloat4)
|
||||
template <>
|
||||
struct Extern<math::SimdFloat4> {
|
||||
struct OZZ_BASE_DLL Extern<math::SimdFloat4> {
|
||||
static void Save(OArchive& _archive, const math::SimdFloat4* _values,
|
||||
size_t _count);
|
||||
static void Load(IArchive& _archive, math::SimdFloat4* _values, size_t _count,
|
||||
@@ -45,7 +45,7 @@ struct Extern<math::SimdFloat4> {
|
||||
|
||||
OZZ_IO_TYPE_NOT_VERSIONABLE(math::SimdInt4)
|
||||
template <>
|
||||
struct Extern<math::SimdInt4> {
|
||||
struct OZZ_BASE_DLL Extern<math::SimdInt4> {
|
||||
static void Save(OArchive& _archive, const math::SimdInt4* _values,
|
||||
size_t _count);
|
||||
static void Load(IArchive& _archive, math::SimdInt4* _values, size_t _count,
|
||||
@@ -54,7 +54,7 @@ struct Extern<math::SimdInt4> {
|
||||
|
||||
OZZ_IO_TYPE_NOT_VERSIONABLE(math::Float4x4)
|
||||
template <>
|
||||
struct Extern<math::Float4x4> {
|
||||
struct OZZ_BASE_DLL Extern<math::Float4x4> {
|
||||
static void Save(OArchive& _archive, const math::Float4x4* _values,
|
||||
size_t _count);
|
||||
static void Load(IArchive& _archive, math::Float4x4* _values, size_t _count,
|
||||
|
||||
@@ -43,7 +43,7 @@ struct SoaTransform;
|
||||
namespace io {
|
||||
OZZ_IO_TYPE_NOT_VERSIONABLE(math::SoaFloat2)
|
||||
template <>
|
||||
struct Extern<math::SoaFloat2> {
|
||||
struct OZZ_BASE_DLL Extern<math::SoaFloat2> {
|
||||
static void Save(OArchive& _archive, const math::SoaFloat2* _values,
|
||||
size_t _count);
|
||||
static void Load(IArchive& _archive, math::SoaFloat2* _values, size_t _count,
|
||||
@@ -52,7 +52,7 @@ struct Extern<math::SoaFloat2> {
|
||||
|
||||
OZZ_IO_TYPE_NOT_VERSIONABLE(math::SoaFloat3)
|
||||
template <>
|
||||
struct Extern<math::SoaFloat3> {
|
||||
struct OZZ_BASE_DLL Extern<math::SoaFloat3> {
|
||||
static void Save(OArchive& _archive, const math::SoaFloat3* _values,
|
||||
size_t _count);
|
||||
static void Load(IArchive& _archive, math::SoaFloat3* _values, size_t _count,
|
||||
@@ -61,7 +61,7 @@ struct Extern<math::SoaFloat3> {
|
||||
|
||||
OZZ_IO_TYPE_NOT_VERSIONABLE(math::SoaFloat4)
|
||||
template <>
|
||||
struct Extern<math::SoaFloat4> {
|
||||
struct OZZ_BASE_DLL Extern<math::SoaFloat4> {
|
||||
static void Save(OArchive& _archive, const math::SoaFloat4* _values,
|
||||
size_t _count);
|
||||
static void Load(IArchive& _archive, math::SoaFloat4* _values, size_t _count,
|
||||
@@ -70,7 +70,7 @@ struct Extern<math::SoaFloat4> {
|
||||
|
||||
OZZ_IO_TYPE_NOT_VERSIONABLE(math::SoaQuaternion)
|
||||
template <>
|
||||
struct Extern<math::SoaQuaternion> {
|
||||
struct OZZ_BASE_DLL Extern<math::SoaQuaternion> {
|
||||
static void Save(OArchive& _archive, const math::SoaQuaternion* _values,
|
||||
size_t _count);
|
||||
static void Load(IArchive& _archive, math::SoaQuaternion* _values,
|
||||
@@ -79,7 +79,7 @@ struct Extern<math::SoaQuaternion> {
|
||||
|
||||
OZZ_IO_TYPE_NOT_VERSIONABLE(math::SoaFloat4x4)
|
||||
template <>
|
||||
struct Extern<math::SoaFloat4x4> {
|
||||
struct OZZ_BASE_DLL Extern<math::SoaFloat4x4> {
|
||||
static void Save(OArchive& _archive, const math::SoaFloat4x4* _values,
|
||||
size_t _count);
|
||||
static void Load(IArchive& _archive, math::SoaFloat4x4* _values,
|
||||
@@ -88,7 +88,7 @@ struct Extern<math::SoaFloat4x4> {
|
||||
|
||||
OZZ_IO_TYPE_NOT_VERSIONABLE(math::SoaTransform)
|
||||
template <>
|
||||
struct Extern<math::SoaTransform> {
|
||||
struct OZZ_BASE_DLL Extern<math::SoaTransform> {
|
||||
static void Save(OArchive& _archive, const math::SoaTransform* _values,
|
||||
size_t _count);
|
||||
static void Load(IArchive& _archive, math::SoaTransform* _values,
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace math {
|
||||
|
||||
// Stores an affine transformation with separate translation, rotation and scale
|
||||
// attributes.
|
||||
struct Transform {
|
||||
struct OZZ_BASE_DLL Transform {
|
||||
// Translation affine transformation component.
|
||||
Float3 translation;
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace ozz {
|
||||
namespace math {
|
||||
|
||||
// Declares a 2d float vector.
|
||||
struct Float2 {
|
||||
struct OZZ_BASE_DLL Float2 {
|
||||
float x, y;
|
||||
|
||||
// Constructs an uninitialized vector.
|
||||
@@ -64,7 +64,7 @@ struct Float2 {
|
||||
};
|
||||
|
||||
// Declares a 3d float vector.
|
||||
struct Float3 {
|
||||
struct OZZ_BASE_DLL Float3 {
|
||||
float x, y, z;
|
||||
|
||||
// Constructs an uninitialized vector.
|
||||
@@ -96,7 +96,7 @@ struct Float3 {
|
||||
};
|
||||
|
||||
// Declares a 4d float vector.
|
||||
struct Float4 {
|
||||
struct OZZ_BASE_DLL Float4 {
|
||||
float x, y, z, w;
|
||||
|
||||
// Constructs an uninitialized vector.
|
||||
|
||||
@@ -41,18 +41,18 @@ namespace memory {
|
||||
class Allocator;
|
||||
|
||||
// Defines the default allocator accessor.
|
||||
Allocator* default_allocator();
|
||||
OZZ_BASE_DLL Allocator* default_allocator();
|
||||
|
||||
// Set the default allocator, used for all dynamic allocation inside ozz.
|
||||
// Returns current memory allocator, such that in can be restored if needed.
|
||||
Allocator* SetDefaulAllocator(Allocator* _allocator);
|
||||
OZZ_BASE_DLL Allocator* SetDefaulAllocator(Allocator* _allocator);
|
||||
|
||||
// Defines an abstract allocator class.
|
||||
// Implements helper methods to allocate/deallocate POD typed objects instead of
|
||||
// raw memory.
|
||||
// Implements New and Delete function to allocate C++ objects, as a replacement
|
||||
// of new and delete operators.
|
||||
class Allocator {
|
||||
class OZZ_BASE_DLL Allocator {
|
||||
public:
|
||||
// Default virtual destructor.
|
||||
virtual ~Allocator() {}
|
||||
|
||||
+6
-1
@@ -41,8 +41,13 @@
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
|
||||
#include "ozz/base/export.h"
|
||||
|
||||
namespace ozz {
|
||||
|
||||
// Defines a byte type, unsigned so right shift doesn't propagate sign bit.
|
||||
typedef uint8_t byte;
|
||||
|
||||
// Finds the number of elements of a statically allocated array.
|
||||
#define OZZ_ARRAY_SIZE(_array) (sizeof(_array) / sizeof(_array[0]))
|
||||
|
||||
@@ -80,7 +85,7 @@ namespace ozz {
|
||||
// Case sensitive wildcard string matching:
|
||||
// - a ? sign matches any character, except an empty string.
|
||||
// - a * sign matches any string, including an empty string.
|
||||
bool strmatch(const char* _str, const char* _pattern);
|
||||
OZZ_BASE_DLL bool strmatch(const char* _str, const char* _pattern);
|
||||
|
||||
// Tests whether _block is aligned to _alignment boundary.
|
||||
template <typename _Ty>
|
||||
|
||||
+27
-17
@@ -52,7 +52,8 @@ struct span {
|
||||
span() : data_(nullptr), size_(0) {}
|
||||
|
||||
// Constructs a range from its extreme values.
|
||||
span(_Ty* _begin, _Ty* _end) : data_(_begin), size_(static_cast<size_t>(_end - _begin)) {
|
||||
span(_Ty* _begin, _Ty* _end)
|
||||
: data_(_begin), size_(static_cast<size_t>(_end - _begin)) {
|
||||
assert(_begin <= _end && "Invalid range.");
|
||||
}
|
||||
|
||||
@@ -84,6 +85,25 @@ struct span {
|
||||
// Implement cast operator to allow conversions to span<const _Ty>.
|
||||
operator span<const _Ty>() const { return span<const _Ty>(data_, size_); }
|
||||
|
||||
// Subspan
|
||||
|
||||
span<element_type> first(index_type _count) const {
|
||||
assert(_count <= size_ && "Count out of range");
|
||||
return {data(), _count};
|
||||
}
|
||||
|
||||
span<element_type> last(index_type _count) const {
|
||||
assert(_count <= size_ && "Count out of range");
|
||||
return {data() + size_ - _count, _count};
|
||||
}
|
||||
|
||||
span<element_type> subspan(index_type _offset, index_type _count) const {
|
||||
assert(_offset <= size_ && "Offset out of range");
|
||||
assert(_count <= size_ && "Count out of range");
|
||||
assert(_offset <= size_ - _count && "Offset + count out of range");
|
||||
return {data_ + _offset, _count};
|
||||
}
|
||||
|
||||
// Returns a const reference to element _i of range [begin,end[.
|
||||
_Ty& operator[](size_t _i) const {
|
||||
assert(_i < size_ && "Index out of range.");
|
||||
@@ -135,35 +155,25 @@ inline span<const typename _Container::value_type> make_span(
|
||||
|
||||
// As bytes
|
||||
template <typename _Ty>
|
||||
inline span<const char> as_bytes(const span<_Ty>& _span) {
|
||||
return {reinterpret_cast<const char*>(_span.data()), _span.size_bytes()};
|
||||
inline span<const byte> as_bytes(const span<_Ty>& _span) {
|
||||
return {reinterpret_cast<const byte*>(_span.data()), _span.size_bytes()};
|
||||
}
|
||||
|
||||
template <typename _Ty>
|
||||
inline span<char> as_writable_bytes(const span<_Ty>& _span) {
|
||||
inline span<byte> as_writable_bytes(const span<_Ty>& _span) {
|
||||
// Compilation will fail here if _Ty is const. This prevents from writing to
|
||||
// const data.
|
||||
return {reinterpret_cast<char*>(_span.data()), _span.size_bytes()};
|
||||
}
|
||||
|
||||
template <>
|
||||
inline span<const char> as_bytes(const span<char>& _span) {
|
||||
return _span;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline span<char> as_writable_bytes(const span<char>& _span) {
|
||||
return _span;
|
||||
return {reinterpret_cast<byte*>(_span.data()), _span.size_bytes()};
|
||||
}
|
||||
|
||||
// Fills a typed span from a byte source span. Source byte span is modified to
|
||||
// reflect remain size.
|
||||
template <typename _Ty>
|
||||
inline span<_Ty> fill_span(span<char>& _src, size_t _count) {
|
||||
inline span<_Ty> fill_span(span<byte>& _src, size_t _count) {
|
||||
assert(ozz::IsAligned(_src.data(), alignof(_Ty)) && "Invalid alignment.");
|
||||
const span<_Ty> ret = {reinterpret_cast<_Ty*>(_src.data()), _count};
|
||||
// Validity assertion is done by span constructor.
|
||||
_src = {reinterpret_cast<char*>(ret.end()), _src.end()};
|
||||
_src = {reinterpret_cast<byte*>(ret.end()), _src.end()};
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user