feat: add clearMorphAnimationData function

This commit is contained in:
Nick Fisher
2024-07-23 09:37:08 +08:00
parent d745712650
commit 41bf9ededa
12 changed files with 105 additions and 15 deletions

View File

@@ -781,6 +781,27 @@ namespace thermion_filament
return true;
}
void SceneManager::clearMorphAnimationBuffer(
EntityId entityId)
{
std::lock_guard lock(_mutex);
auto entity = Entity::import(entityId);
if (entity.isNull())
{
Log("ERROR: invalid entity %d.", entityId);
return;
}
auto animationComponentInstance = _animationComponentManager->getInstance(entity);
auto &animationComponent = _animationComponentManager->elementAt<0>(animationComponentInstance);
auto &morphAnimations = animationComponent.morphAnimations;
morphAnimations.clear();
return;
}
bool SceneManager::setMaterialColor(EntityId entityId, const char *meshName, int materialIndex, const float r, const float g, const float b, const float a)
{

View File

@@ -405,7 +405,7 @@ extern "C"
return ((SceneManager *)sceneManager)->setMorphTargetWeights(asset, weights, numWeights);
}
bool set_morph_animation(
EMSCRIPTEN_KEEPALIVE bool set_morph_animation(
void *sceneManager,
EntityId asset,
const float *const morphData,
@@ -418,6 +418,10 @@ extern "C"
return result;
}
EMSCRIPTEN_KEEPALIVE void clear_morph_animation(void* sceneManager, EntityId asset) {
((SceneManager *)sceneManager)->clearMorphAnimationBuffer(asset);
}
EMSCRIPTEN_KEEPALIVE void reset_to_rest_pose(void *sceneManager, EntityId entityId)
{
((SceneManager *)sceneManager)->resetBones(entityId);