add getAnimationDuration method

This commit is contained in:
Nick Fisher
2023-08-08 14:34:15 +08:00
parent fb53881183
commit fa8c6b1ca0
6 changed files with 40 additions and 4 deletions

View File

@@ -708,6 +708,20 @@ void AssetManager::setAnimationFrame(EntityId entity, int animationIndex, int an
asset.mAnimator->updateBoneMatrices();
}
float AssetManager::getAnimationDuration(EntityId entity, int animationIndex) {
const auto& pos = _entityIdLookup.find(entity);
unique_ptr<vector<string>> names = make_unique<vector<string>>();
if(pos == _entityIdLookup.end()) {
Log("ERROR: asset not found for entity id.");
return -1.0f;
}
auto& asset = _assets[pos->second];
return asset.mAnimator->getAnimationDuration(animationIndex);
}
unique_ptr<vector<string>> AssetManager::getAnimationNames(EntityId entity) {
const auto& pos = _entityIdLookup.find(entity);

View File

@@ -280,15 +280,16 @@ extern "C" {
// ((AssetManager*)assetManager)->setAnimationFrame(asset, animationIndex, animationFrame);
}
FLUTTER_PLUGIN_EXPORT float get_animation_duration(void* assetManager, EntityId asset, int animationIndex) {
return ((AssetManager*)assetManager)->getAnimationDuration(asset, animationIndex);
}
FLUTTER_PLUGIN_EXPORT int get_animation_count(
void* assetManager,
EntityId asset) {
//std::packaged_task<int()> lambda([=]() mutable {
auto names = ((AssetManager*)assetManager)->getAnimationNames(asset);
return names->size();
//return fut.get();
}
FLUTTER_PLUGIN_EXPORT void get_animation_name(