add loop option to playAnimation and fix animation names

This commit is contained in:
Nick Fisher
2022-03-29 15:48:39 +08:00
parent 473ba59b27
commit 0944a8df66

View File

@@ -123,9 +123,9 @@ extern "C" {
((FilamentViewer*)viewer)->animateWeights((float*)data, numWeights, numFrames, frameRate); ((FilamentViewer*)viewer)->animateWeights((float*)data, numWeights, numFrames, frameRate);
} }
void play_animation(void* viewer, int index) { void play_animation(void* viewer, int index, bool loop) {
__android_log_print(ANDROID_LOG_VERBOSE, "filament_api", "Playing embedded animation %d", index); __android_log_print(ANDROID_LOG_VERBOSE, "filament_api", "Playing embedded animation %d", index);
((FilamentViewer*)viewer)->playAnimation(index); ((FilamentViewer*)viewer)->playAnimation(index, loop);
} }
char** get_animation_names(void* viewer, int* countPtr) { char** get_animation_names(void* viewer, int* countPtr) {
@@ -134,8 +134,10 @@ extern "C" {
char** names_c; char** names_c;
names_c = new char*[names->size()]; names_c = new char*[names->size()];
for(int i = 0; i < names->size(); i++) { for(int i = 0; i < names->size(); i++) {
names_c[i] = (char*) names->at(i).c_str(); __android_log_print(ANDROID_LOG_VERBOSE, "filament_api", "Memcpy %d bytes ", names->at(i).size());
__android_log_print(ANDROID_LOG_VERBOSE, "filament_api", "Alloced animation name %s ", (char*) names->at(i).c_str()); names_c[i] = (char*) malloc(names->at(i).size() +1);
strcpy(names_c[i], names->at(i).c_str());
__android_log_print(ANDROID_LOG_VERBOSE, "filament_api", "Alloced animation name %s ", (char*) names_c[i]);
} }
(*countPtr) = names->size(); (*countPtr) = names->size();
return names_c; return names_c;