add getAnimationDuration method
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user