restructure render loop to correct timings and expose FFI methods for setBoneTransform/setMorphWeights
This commit is contained in:
@@ -280,16 +280,6 @@ namespace polyvox
|
||||
return _assets[pos->second].asset;
|
||||
}
|
||||
|
||||
// vector<int> completedBoneAnimations;
|
||||
|
||||
// for (int i = completed.size() - 1; i >= 0; i--) {
|
||||
// auto completedAnimationIndex = completed[i];
|
||||
// if(asset.animations.mType == AnimationType::BONE) {
|
||||
// completedBoneAnimations.push_back()
|
||||
// }
|
||||
// (completedAnimationIndex);
|
||||
// }
|
||||
|
||||
void AssetManager::updateAnimations()
|
||||
{
|
||||
|
||||
@@ -390,10 +380,13 @@ namespace polyvox
|
||||
}
|
||||
}
|
||||
|
||||
// TODO - we really don't want to be looking up the bone index/entity by name every single frame
|
||||
// - could use findChildEntityByName
|
||||
// - or is it better to add an option for "streaming" mode where we can just return a reference to a mat4 and then update the values directly?
|
||||
bool AssetManager::setBoneTransform(EntityId entityId, const char *entityName, int32_t skinIndex, const char* boneName, math::mat4f localTransform)
|
||||
{
|
||||
|
||||
Log("Setting transform for bone %s/skin %d for mesh target %s", boneName, skinIndex, entityName);
|
||||
std::lock_guard lock(_animationMutex);
|
||||
|
||||
const auto &pos = _entityIdLookup.find(entityId);
|
||||
if (pos == _entityIdLookup.end())
|
||||
@@ -414,6 +407,11 @@ namespace polyvox
|
||||
|
||||
const auto &renderableInstance = rm.getInstance(entity);
|
||||
|
||||
if(!renderableInstance.isValid()) {
|
||||
Log("Invalid renderable");
|
||||
return false;
|
||||
}
|
||||
|
||||
TransformManager &transformManager = _engine->getTransformManager();
|
||||
|
||||
const auto &filamentInstance = sceneAsset.asset->getInstance();
|
||||
@@ -442,6 +440,7 @@ namespace polyvox
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
utils::Entity joint = filamentInstance->getJointsAt(skinIndex)[boneIndex];
|
||||
|
||||
if (joint.isNull())
|
||||
@@ -577,6 +576,28 @@ namespace polyvox
|
||||
count);
|
||||
}
|
||||
|
||||
utils::Entity AssetManager::findChildEntityByName(EntityId entityId, const char *entityName) {
|
||||
std::lock_guard lock(_animationMutex);
|
||||
|
||||
const auto &pos = _entityIdLookup.find(entityId);
|
||||
if (pos == _entityIdLookup.end())
|
||||
{
|
||||
Log("Couldn't find asset under specified entity id.");
|
||||
return utils::Entity();
|
||||
}
|
||||
SceneAsset &sceneAsset = _assets[pos->second];
|
||||
|
||||
const auto entity = findEntityByName(sceneAsset, entityName);
|
||||
|
||||
if(entity.isNull()) {
|
||||
Log("Failed to find entity %s.", entityName);
|
||||
}
|
||||
|
||||
return entity;
|
||||
|
||||
}
|
||||
|
||||
|
||||
utils::Entity AssetManager::findEntityByName(SceneAsset asset, const char *entityName)
|
||||
{
|
||||
utils::Entity entity;
|
||||
|
||||
Reference in New Issue
Block a user