#pragma once //////////////////////////////////////////////////////////////////////////////// // The MIT License (MIT) // // Copyright (c) 2020 Nicholas Frechette & Animation Compression Library contributors // // 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. //////////////////////////////////////////////////////////////////////////////// // Included only once from decompress.h #include namespace acl { namespace acl_impl { ////////////////////////////////////////////////////////////////////////// // SFINAE boilerplate to detect if a template argument derives from acl::decompression_context. ////////////////////////////////////////////////////////////////////////// template using is_decompression_context = typename std::enable_if, T>::value, std::nullptr_t>::type; } ////////////////////////////////////////////////////////////////////////// // decompression_context implementation template inline decompression_context::decompression_context() : m_context() { m_context.reset(); } template inline bool decompression_context::initialize(const compressed_tracks& tracks) { const bool is_valid = tracks.is_valid(false).empty(); ACL_ASSERT(is_valid, "Invalid compressed tracks instance"); if (!is_valid) return false; // Invalid compressed tracks instance ACL_ASSERT(algorithm_version_type::is_version_supported(tracks.get_version()), "Unsupported version"); if (!algorithm_version_type::is_version_supported(tracks.get_version())) return false; return algorithm_version_type::template initialize(m_context, tracks); } template inline bool decompression_context::is_dirty(const compressed_tracks& tracks) const { return algorithm_version_type::template is_dirty(m_context, tracks); } template inline void decompression_context::seek(float sample_time, sample_rounding_policy rounding_policy) { ACL_ASSERT(m_context.is_initialized(), "Context is not initialized"); ACL_ASSERT(rtm::scalar_is_finite(sample_time), "Invalid sample time"); if (!m_context.is_initialized()) return; // Context is not initialized algorithm_version_type::template seek(m_context, sample_time, rounding_policy); } template template inline void decompression_context::decompress_tracks(track_writer_type& writer) { static_assert(std::is_base_of::value, "track_writer_type must derive from track_writer"); ACL_ASSERT(m_context.is_initialized(), "Context is not initialized"); if (!m_context.is_initialized()) return; // Context is not initialized algorithm_version_type::template decompress_tracks(m_context, writer); } template template inline void decompression_context::decompress_track(uint32_t track_index, track_writer_type& writer) { static_assert(std::is_base_of::value, "track_writer_type must derive from track_writer"); ACL_ASSERT(m_context.is_initialized(), "Context is not initialized"); if (!m_context.is_initialized()) return; // Context is not initialized algorithm_version_type::template decompress_track(m_context, track_index, writer); } }