This commit is contained in:
Nick Fisher
2024-03-04 15:40:58 +08:00
parent 61299e4587
commit d8ae4c0949

View File

@@ -315,14 +315,14 @@ namespace flutter_filament
if(meshName) { if(meshName) {
entity = findEntityByName(instance, meshName); entity = findEntityByName(instance, meshName);
Log("Hiding child entity under name %s ", meshName); // Log("Hiding child entity under name %s ", meshName);
if (entity.isNull()) { if (entity.isNull()) {
Log("Failed to hide entity; specified mesh name does not exist under the target entity, or the target entity itself is no longer valid."); Log("Failed to hide entity; specified mesh name does not exist under the target entity, or the target entity itself is no longer valid.");
return false; return false;
} }
_scene->remove(entity); _scene->remove(entity);
} else { } else {
Log("Hiding all child entities"); // Log("Hiding all child entities");
auto* entities = instance->getEntities(); auto* entities = instance->getEntities();
for(int i =0; i < instance->getEntityCount(); i++) { for(int i =0; i < instance->getEntityCount(); i++) {
auto entity = entities[i]; auto entity = entities[i];
@@ -357,7 +357,7 @@ namespace flutter_filament
} }
_scene->addEntity(entity); _scene->addEntity(entity);
} else { } else {
Log("Revealing all child entities"); // Log("Revealing all child entities");
auto* entities = instance->getEntities(); auto* entities = instance->getEntities();
for(int i =0; i < instance->getEntityCount(); i++) { for(int i =0; i < instance->getEntityCount(); i++) {
auto entity = entities[i]; auto entity = entities[i];
@@ -1075,17 +1075,16 @@ namespace flutter_filament
float SceneManager::getAnimationDuration(EntityId entity, int animationIndex) float SceneManager::getAnimationDuration(EntityId entity, int animationIndex)
{ {
const auto &pos = _instances.find(entity); auto* instance = getInstanceByEntityId(entity);
unique_ptr<std::vector<std::string>> names = std::make_unique<std::vector<std::string>>(); if (!instance)
if (pos == _instances.end())
{ {
Log("ERROR: asset not found for entity id."); auto* asset = getAssetByEntityId(entity);
return -1.0f; if(!asset) {
return -1.0f;
}
instance = asset->getInstance();
} }
auto *instance = pos->second;
return instance->getAnimator()->getAnimationDuration(animationIndex); return instance->getAnimator()->getAnimationDuration(animationIndex);
} }
@@ -1182,7 +1181,7 @@ namespace flutter_filament
} }
void SceneManager::setParent(EntityId childEntityId, EntityId parentEntityId) { void SceneManager::setParent(EntityId childEntityId, EntityId parentEntityId) {
Log("Parenting child %d to %d", childEntityId, parentEntityId); // Log("Parenting child %d to %d", childEntityId, parentEntityId);
auto& tm = _engine->getTransformManager(); auto& tm = _engine->getTransformManager();
const auto child = Entity::import(childEntityId); const auto child = Entity::import(childEntityId);
const auto parent = Entity::import(parentEntityId); const auto parent = Entity::import(parentEntityId);