remove unused FFI morph animation method
This commit is contained in:
@@ -23,8 +23,7 @@ extern "C"
|
|||||||
const ResourceLoaderWrapper *const loader,
|
const ResourceLoaderWrapper *const loader,
|
||||||
void (*renderCallback)(void *const renderCallbackOwner),
|
void (*renderCallback)(void *const renderCallbackOwner),
|
||||||
void *const renderCallbackOwner,
|
void *const renderCallbackOwner,
|
||||||
void (*callback)(void* const viewer)
|
void (*callback)(void *const viewer));
|
||||||
);
|
|
||||||
FLUTTER_PLUGIN_EXPORT void create_swap_chain_ffi(void *const viewer, void *const surface, uint32_t width, uint32_t height, void (*onComplete)());
|
FLUTTER_PLUGIN_EXPORT void create_swap_chain_ffi(void *const viewer, void *const surface, uint32_t width, uint32_t height, void (*onComplete)());
|
||||||
FLUTTER_PLUGIN_EXPORT void destroy_swap_chain_ffi(void *const viewer, void (*onComplete)());
|
FLUTTER_PLUGIN_EXPORT void destroy_swap_chain_ffi(void *const viewer, void (*onComplete)());
|
||||||
FLUTTER_PLUGIN_EXPORT void create_render_target_ffi(void *const viewer, intptr_t nativeTextureId, uint32_t width, uint32_t height, void (*onComplete)());
|
FLUTTER_PLUGIN_EXPORT void create_render_target_ffi(void *const viewer, intptr_t nativeTextureId, uint32_t width, uint32_t height, void (*onComplete)());
|
||||||
@@ -82,19 +81,10 @@ extern "C"
|
|||||||
FLUTTER_PLUGIN_EXPORT void get_morph_target_name_count_ffi(void *const sceneManager, EntityId asset, const char *meshName, void (*callback)(int32_t));
|
FLUTTER_PLUGIN_EXPORT void get_morph_target_name_count_ffi(void *const sceneManager, EntityId asset, const char *meshName, void (*callback)(int32_t));
|
||||||
FLUTTER_PLUGIN_EXPORT void set_morph_target_weights_ffi(void *const sceneManager,
|
FLUTTER_PLUGIN_EXPORT void set_morph_target_weights_ffi(void *const sceneManager,
|
||||||
EntityId asset,
|
EntityId asset,
|
||||||
const char *const entityName,
|
|
||||||
const float *const morphData,
|
const float *const morphData,
|
||||||
int numWeights);
|
int numWeights,
|
||||||
FLUTTER_PLUGIN_EXPORT void set_morph_animation_ffi(
|
|
||||||
void *sceneManager,
|
|
||||||
EntityId asset,
|
|
||||||
const char *const entityName,
|
|
||||||
const float *const morphData,
|
|
||||||
const int *const morphIndices,
|
|
||||||
int numMorphTargets,
|
|
||||||
int numFrames,
|
|
||||||
float frameLengthInMs,
|
|
||||||
void (*callback)(bool));
|
void (*callback)(bool));
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void set_bone_transform_ffi(
|
FLUTTER_PLUGIN_EXPORT void set_bone_transform_ffi(
|
||||||
void *sceneManager,
|
void *sceneManager,
|
||||||
EntityId asset,
|
EntityId asset,
|
||||||
|
|||||||
@@ -34,10 +34,13 @@ extern "C"
|
|||||||
using namespace flutter_filament;
|
using namespace flutter_filament;
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
class RenderLoop {
|
class RenderLoop
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
explicit RenderLoop() {
|
explicit RenderLoop()
|
||||||
_t = new std::thread([this]() {
|
{
|
||||||
|
_t = new std::thread([this]()
|
||||||
|
{
|
||||||
auto last = std::chrono::high_resolution_clock::now();
|
auto last = std::chrono::high_resolution_clock::now();
|
||||||
while (!_stop) {
|
while (!_stop) {
|
||||||
|
|
||||||
@@ -72,10 +75,10 @@ public:
|
|||||||
auto sleepFor = std::chrono::microseconds(int(_frameIntervalInMilliseconds - elapsed) * 1000);
|
auto sleepFor = std::chrono::microseconds(int(_frameIntervalInMilliseconds - elapsed) * 1000);
|
||||||
std::this_thread::sleep_for(sleepFor);
|
std::this_thread::sleep_for(sleepFor);
|
||||||
}
|
}
|
||||||
|
} });
|
||||||
}
|
}
|
||||||
});
|
~RenderLoop()
|
||||||
}
|
{
|
||||||
~RenderLoop() {
|
|
||||||
_stop = true;
|
_stop = true;
|
||||||
_t->join();
|
_t->join();
|
||||||
}
|
}
|
||||||
@@ -85,11 +88,13 @@ public:
|
|||||||
const ResourceLoaderWrapper *const loader,
|
const ResourceLoaderWrapper *const loader,
|
||||||
void (*renderCallback)(void *),
|
void (*renderCallback)(void *),
|
||||||
void *const owner,
|
void *const owner,
|
||||||
void (*callback)(void* const) ) {
|
void (*callback)(void *const))
|
||||||
|
{
|
||||||
_renderCallback = renderCallback;
|
_renderCallback = renderCallback;
|
||||||
_renderCallbackOwner = owner;
|
_renderCallbackOwner = owner;
|
||||||
std::packaged_task<FilamentViewer *()> lambda([=]() mutable {
|
std::packaged_task<FilamentViewer *()> lambda([=]() mutable
|
||||||
#ifdef __EMSCRIPTEN__
|
{
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
auto emContext = flutter_filament_web_create_gl_context();
|
auto emContext = flutter_filament_web_create_gl_context();
|
||||||
|
|
||||||
auto success = emscripten_webgl_make_context_current((EMSCRIPTEN_WEBGL_CONTEXT_HANDLE)emContext);
|
auto success = emscripten_webgl_make_context_current((EMSCRIPTEN_WEBGL_CONTEXT_HANDLE)emContext);
|
||||||
@@ -98,55 +103,61 @@ public:
|
|||||||
return (FilamentViewer*)nullptr;
|
return (FilamentViewer*)nullptr;
|
||||||
}
|
}
|
||||||
_viewer = new FilamentViewer((void* const) emContext, loader, platform, uberArchivePath);
|
_viewer = new FilamentViewer((void* const) emContext, loader, platform, uberArchivePath);
|
||||||
#else
|
#else
|
||||||
_viewer = new FilamentViewer(context, loader, platform, uberArchivePath);
|
_viewer = new FilamentViewer(context, loader, platform, uberArchivePath);
|
||||||
#endif
|
#endif
|
||||||
callback(_viewer);
|
callback(_viewer);
|
||||||
return _viewer;
|
return _viewer; });
|
||||||
});
|
|
||||||
auto fut = add_task(lambda);
|
auto fut = add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroyViewer() {
|
void destroyViewer()
|
||||||
std::packaged_task<void()> lambda([=]() mutable {
|
{
|
||||||
|
std::packaged_task<void()> lambda([=]() mutable
|
||||||
|
{
|
||||||
_rendering = false;
|
_rendering = false;
|
||||||
destroy_filament_viewer(_viewer);
|
destroy_filament_viewer(_viewer);
|
||||||
_viewer = nullptr;
|
_viewer = nullptr; });
|
||||||
});
|
|
||||||
auto fut = add_task(lambda);
|
auto fut = add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setRendering(bool rendering) {
|
void setRendering(bool rendering)
|
||||||
|
{
|
||||||
std::packaged_task<void()> lambda(
|
std::packaged_task<void()> lambda(
|
||||||
[=]() mutable { this->_rendering = rendering; });
|
[=]() mutable
|
||||||
|
{ this->_rendering = rendering; });
|
||||||
auto fut = add_task(lambda);
|
auto fut = add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
void doRender() {
|
void doRender()
|
||||||
|
{
|
||||||
// auto now = std::chrono::high_resolution_clock::now();
|
// auto now = std::chrono::high_resolution_clock::now();
|
||||||
// auto nanos = std::chrono::duration_cast<std::chrono::nanoseconds>(now.time_since_epoch()).count();
|
// auto nanos = std::chrono::duration_cast<std::chrono::nanoseconds>(now.time_since_epoch()).count();
|
||||||
render(_viewer, 0, nullptr, nullptr, nullptr);
|
render(_viewer, 0, nullptr, nullptr, nullptr);
|
||||||
_lastRenderTime = std::chrono::high_resolution_clock::now();
|
_lastRenderTime = std::chrono::high_resolution_clock::now();
|
||||||
if(_renderCallback) {
|
if (_renderCallback)
|
||||||
|
{
|
||||||
_renderCallback(_renderCallbackOwner);
|
_renderCallback(_renderCallbackOwner);
|
||||||
}
|
}
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
emscripten_webgl_commit_frame();
|
emscripten_webgl_commit_frame();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setFrameIntervalInMilliseconds(float frameIntervalInMilliseconds) {
|
void setFrameIntervalInMilliseconds(float frameIntervalInMilliseconds)
|
||||||
|
{
|
||||||
_frameIntervalInMilliseconds = frameIntervalInMilliseconds;
|
_frameIntervalInMilliseconds = frameIntervalInMilliseconds;
|
||||||
Log("Set _frameIntervalInMilliseconds to %f", _frameIntervalInMilliseconds);
|
Log("Set _frameIntervalInMilliseconds to %f", _frameIntervalInMilliseconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Rt>
|
template <class Rt>
|
||||||
auto add_task(std::packaged_task<Rt()> &pt) -> std::future<Rt> {
|
auto add_task(std::packaged_task<Rt()> &pt) -> std::future<Rt>
|
||||||
|
{
|
||||||
std::unique_lock<std::mutex> lock(_access);
|
std::unique_lock<std::mutex> lock(_access);
|
||||||
auto ret = pt.get_future();
|
auto ret = pt.get_future();
|
||||||
_tasks.push_back([pt = std::make_shared<std::packaged_task<Rt()>>(
|
_tasks.push_back([pt = std::make_shared<std::packaged_task<Rt()>>(
|
||||||
std::move(pt))] { (*pt)(); });
|
std::move(pt))]
|
||||||
|
{ (*pt)(); });
|
||||||
_cond.notify_one();
|
_cond.notify_one();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -165,396 +176,447 @@ private:
|
|||||||
std::chrono::steady_clock::time_point _lastRenderTime = std::chrono::high_resolution_clock::now();
|
std::chrono::steady_clock::time_point _lastRenderTime = std::chrono::high_resolution_clock::now();
|
||||||
};
|
};
|
||||||
|
|
||||||
extern "C" {
|
extern "C"
|
||||||
|
{
|
||||||
|
|
||||||
static RenderLoop *_rl;
|
static RenderLoop *_rl;
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void create_filament_viewer_ffi(
|
FLUTTER_PLUGIN_EXPORT void create_filament_viewer_ffi(
|
||||||
void *const context, void *const platform, const char *uberArchivePath,
|
void *const context, void *const platform, const char *uberArchivePath,
|
||||||
const ResourceLoaderWrapper *const loader,
|
const ResourceLoaderWrapper *const loader,
|
||||||
void (*renderCallback)(void *const renderCallbackOwner),
|
void (*renderCallback)(void *const renderCallbackOwner),
|
||||||
void *const renderCallbackOwner,
|
void *const renderCallbackOwner,
|
||||||
void (*callback)(void* const) ) {
|
void (*callback)(void *const))
|
||||||
if (!_rl) {
|
{
|
||||||
|
if (!_rl)
|
||||||
|
{
|
||||||
_rl = new RenderLoop();
|
_rl = new RenderLoop();
|
||||||
}
|
}
|
||||||
_rl->createViewer(context, platform, uberArchivePath, loader,
|
_rl->createViewer(context, platform, uberArchivePath, loader,
|
||||||
renderCallback, renderCallbackOwner, callback);
|
renderCallback, renderCallbackOwner, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void destroy_filament_viewer_ffi(void *const viewer) {
|
FLUTTER_PLUGIN_EXPORT void destroy_filament_viewer_ffi(void *const viewer)
|
||||||
|
{
|
||||||
_rl->destroyViewer();
|
_rl->destroyViewer();
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void create_swap_chain_ffi(void *const viewer,
|
FLUTTER_PLUGIN_EXPORT void create_swap_chain_ffi(void *const viewer,
|
||||||
void *const surface,
|
void *const surface,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height,
|
uint32_t height,
|
||||||
void (*onComplete)()) {
|
void (*onComplete)())
|
||||||
|
{
|
||||||
Log("Creating swapchain %dx%d with viewer %d", width, height, viewer);
|
Log("Creating swapchain %dx%d with viewer %d", width, height, viewer);
|
||||||
std::packaged_task<void()> lambda(
|
std::packaged_task<void()> lambda(
|
||||||
[=]() mutable {
|
[=]() mutable
|
||||||
|
{
|
||||||
create_swap_chain(viewer, surface, width, height);
|
create_swap_chain(viewer, surface, width, height);
|
||||||
onComplete();
|
onComplete();
|
||||||
});
|
});
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void destroy_swap_chain_ffi(void *const viewer, void (*onComplete)()) {
|
FLUTTER_PLUGIN_EXPORT void destroy_swap_chain_ffi(void *const viewer, void (*onComplete)())
|
||||||
|
{
|
||||||
Log("Destroying swapchain");
|
Log("Destroying swapchain");
|
||||||
std::packaged_task<void()> lambda(
|
std::packaged_task<void()> lambda(
|
||||||
[=]() mutable {
|
[=]() mutable
|
||||||
|
{
|
||||||
destroy_swap_chain(viewer);
|
destroy_swap_chain(viewer);
|
||||||
onComplete();
|
onComplete();
|
||||||
});
|
});
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void create_render_target_ffi(void *const viewer,
|
FLUTTER_PLUGIN_EXPORT void create_render_target_ffi(void *const viewer,
|
||||||
intptr_t nativeTextureId,
|
intptr_t nativeTextureId,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height,
|
uint32_t height,
|
||||||
void (*onComplete)()) {
|
void (*onComplete)())
|
||||||
std::packaged_task<void()> lambda([=]() mutable {
|
{
|
||||||
|
std::packaged_task<void()> lambda([=]() mutable
|
||||||
|
{
|
||||||
create_render_target(viewer, nativeTextureId, width, height);
|
create_render_target(viewer, nativeTextureId, width, height);
|
||||||
onComplete();
|
onComplete(); });
|
||||||
});
|
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void update_viewport_and_camera_projection_ffi(
|
FLUTTER_PLUGIN_EXPORT void update_viewport_and_camera_projection_ffi(
|
||||||
void *const viewer, const uint32_t width, const uint32_t height,
|
void *const viewer, const uint32_t width, const uint32_t height,
|
||||||
const float scaleFactor,
|
const float scaleFactor,
|
||||||
void (*onComplete)()) {
|
void (*onComplete)())
|
||||||
|
{
|
||||||
Log("Update viewport %dx%d", width, height);
|
Log("Update viewport %dx%d", width, height);
|
||||||
std::packaged_task<void()> lambda([=]() mutable {
|
std::packaged_task<void()> lambda([=]() mutable
|
||||||
|
{
|
||||||
update_viewport_and_camera_projection(viewer, width, height, scaleFactor);
|
update_viewport_and_camera_projection(viewer, width, height, scaleFactor);
|
||||||
onComplete();
|
onComplete(); });
|
||||||
});
|
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void set_rendering_ffi(void *const viewer,
|
FLUTTER_PLUGIN_EXPORT void set_rendering_ffi(void *const viewer,
|
||||||
bool rendering) {
|
bool rendering)
|
||||||
if (!_rl) {
|
{
|
||||||
|
if (!_rl)
|
||||||
|
{
|
||||||
Log("No render loop!"); // PANIC?
|
Log("No render loop!"); // PANIC?
|
||||||
} else {
|
}
|
||||||
if (rendering) {
|
else
|
||||||
|
{
|
||||||
|
if (rendering)
|
||||||
|
{
|
||||||
Log("Set rendering to true");
|
Log("Set rendering to true");
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
Log("Set rendering to false");
|
Log("Set rendering to false");
|
||||||
}
|
}
|
||||||
_rl->setRendering(rendering);
|
_rl->setRendering(rendering);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void
|
FLUTTER_PLUGIN_EXPORT void
|
||||||
set_frame_interval_ffi(float frameIntervalInMilliseconds) {
|
set_frame_interval_ffi(float frameIntervalInMilliseconds)
|
||||||
|
{
|
||||||
_rl->setFrameIntervalInMilliseconds(frameIntervalInMilliseconds);
|
_rl->setFrameIntervalInMilliseconds(frameIntervalInMilliseconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void render_ffi(void *const viewer) {
|
FLUTTER_PLUGIN_EXPORT void render_ffi(void *const viewer)
|
||||||
std::packaged_task<void()> lambda([=]() mutable { _rl->doRender(); });
|
{
|
||||||
|
std::packaged_task<void()> lambda([=]() mutable
|
||||||
|
{ _rl->doRender(); });
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void
|
FLUTTER_PLUGIN_EXPORT void
|
||||||
set_background_color_ffi(void *const viewer, const float r, const float g,
|
set_background_color_ffi(void *const viewer, const float r, const float g,
|
||||||
const float b, const float a) {
|
const float b, const float a)
|
||||||
|
{
|
||||||
std::packaged_task<void()> lambda(
|
std::packaged_task<void()> lambda(
|
||||||
[=]() mutable { set_background_color(viewer, r, g, b, a); });
|
[=]() mutable
|
||||||
|
{ set_background_color(viewer, r, g, b, a); });
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void load_gltf_ffi(void *const sceneManager,
|
FLUTTER_PLUGIN_EXPORT void load_gltf_ffi(void *const sceneManager,
|
||||||
const char *path,
|
const char *path,
|
||||||
const char *relativeResourcePath,
|
const char *relativeResourcePath,
|
||||||
void (*callback)(EntityId)) {
|
void (*callback)(EntityId))
|
||||||
std::packaged_task<EntityId()> lambda([=]() mutable {
|
{
|
||||||
|
std::packaged_task<EntityId()> lambda([=]() mutable
|
||||||
|
{
|
||||||
auto entity = load_gltf(sceneManager, path, relativeResourcePath);
|
auto entity = load_gltf(sceneManager, path, relativeResourcePath);
|
||||||
callback(entity);
|
callback(entity);
|
||||||
return entity;
|
return entity; });
|
||||||
});
|
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void load_glb_ffi(void *const sceneManager,
|
FLUTTER_PLUGIN_EXPORT void load_glb_ffi(void *const sceneManager,
|
||||||
const char *path, int numInstances, void (*callback)(EntityId)) {
|
const char *path, int numInstances, void (*callback)(EntityId))
|
||||||
|
{
|
||||||
std::packaged_task<EntityId()> lambda(
|
std::packaged_task<EntityId()> lambda(
|
||||||
[=]() mutable {
|
[=]() mutable
|
||||||
|
{
|
||||||
auto entity = load_glb(sceneManager, path, numInstances);
|
auto entity = load_glb(sceneManager, path, numInstances);
|
||||||
callback(entity);
|
callback(entity);
|
||||||
return entity;
|
return entity;
|
||||||
});
|
});
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void load_glb_from_buffer_ffi(void *const sceneManager,
|
FLUTTER_PLUGIN_EXPORT void load_glb_from_buffer_ffi(void *const sceneManager,
|
||||||
const void *const data, size_t length, int numInstances, void (*callback)(EntityId)) {
|
const void *const data, size_t length, int numInstances, void (*callback)(EntityId))
|
||||||
|
{
|
||||||
std::packaged_task<EntityId()> lambda(
|
std::packaged_task<EntityId()> lambda(
|
||||||
[=]() mutable {
|
[=]() mutable
|
||||||
|
{
|
||||||
auto entity = load_glb_from_buffer(sceneManager, data, length);
|
auto entity = load_glb_from_buffer(sceneManager, data, length);
|
||||||
callback(entity);
|
callback(entity);
|
||||||
return entity;
|
return entity;
|
||||||
});
|
});
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void clear_background_image_ffi(void *const viewer) {
|
FLUTTER_PLUGIN_EXPORT void clear_background_image_ffi(void *const viewer)
|
||||||
std::packaged_task<void()> lambda([=] { clear_background_image(viewer); });
|
{
|
||||||
|
std::packaged_task<void()> lambda([=]
|
||||||
|
{ clear_background_image(viewer); });
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void set_background_image_ffi(void *const viewer,
|
FLUTTER_PLUGIN_EXPORT void set_background_image_ffi(void *const viewer,
|
||||||
const char *path,
|
const char *path,
|
||||||
bool fillHeight, void (*callback)()) {
|
bool fillHeight, void (*callback)())
|
||||||
|
{
|
||||||
std::packaged_task<void()> lambda(
|
std::packaged_task<void()> lambda(
|
||||||
[=] {
|
[=]
|
||||||
|
{
|
||||||
set_background_image(viewer, path, fillHeight);
|
set_background_image(viewer, path, fillHeight);
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
FLUTTER_PLUGIN_EXPORT void set_background_image_position_ffi(void *const viewer,
|
FLUTTER_PLUGIN_EXPORT void set_background_image_position_ffi(void *const viewer,
|
||||||
float x, float y,
|
float x, float y,
|
||||||
bool clamp) {
|
bool clamp)
|
||||||
|
{
|
||||||
std::packaged_task<void()> lambda(
|
std::packaged_task<void()> lambda(
|
||||||
[=] { set_background_image_position(viewer, x, y, clamp); });
|
[=]
|
||||||
|
{ set_background_image_position(viewer, x, y, clamp); });
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
FLUTTER_PLUGIN_EXPORT void set_tone_mapping_ffi(void *const viewer,
|
FLUTTER_PLUGIN_EXPORT void set_tone_mapping_ffi(void *const viewer,
|
||||||
int toneMapping) {
|
int toneMapping)
|
||||||
|
{
|
||||||
std::packaged_task<void()> lambda(
|
std::packaged_task<void()> lambda(
|
||||||
[=] { set_tone_mapping(viewer, toneMapping); });
|
[=]
|
||||||
|
{ set_tone_mapping(viewer, toneMapping); });
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
FLUTTER_PLUGIN_EXPORT void set_bloom_ffi(void *const viewer, float strength) {
|
FLUTTER_PLUGIN_EXPORT void set_bloom_ffi(void *const viewer, float strength)
|
||||||
std::packaged_task<void()> lambda([=] { set_bloom(viewer, strength); });
|
{
|
||||||
|
std::packaged_task<void()> lambda([=]
|
||||||
|
{ set_bloom(viewer, strength); });
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
FLUTTER_PLUGIN_EXPORT void load_skybox_ffi(void *const viewer,
|
FLUTTER_PLUGIN_EXPORT void load_skybox_ffi(void *const viewer,
|
||||||
const char *skyboxPath) {
|
const char *skyboxPath)
|
||||||
std::packaged_task<void()> lambda([=] { load_skybox(viewer, skyboxPath); });
|
{
|
||||||
|
std::packaged_task<void()> lambda([=]
|
||||||
|
{ load_skybox(viewer, skyboxPath); });
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void load_ibl_ffi(void *const viewer, const char *iblPath,
|
FLUTTER_PLUGIN_EXPORT void load_ibl_ffi(void *const viewer, const char *iblPath,
|
||||||
float intensity) {
|
float intensity)
|
||||||
|
{
|
||||||
std::packaged_task<void()> lambda(
|
std::packaged_task<void()> lambda(
|
||||||
[=] { load_ibl(viewer, iblPath, intensity); });
|
[=]
|
||||||
|
{ load_ibl(viewer, iblPath, intensity); });
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
FLUTTER_PLUGIN_EXPORT void remove_skybox_ffi(void *const viewer) {
|
FLUTTER_PLUGIN_EXPORT void remove_skybox_ffi(void *const viewer)
|
||||||
std::packaged_task<void()> lambda([=] { remove_skybox(viewer); });
|
{
|
||||||
|
std::packaged_task<void()> lambda([=]
|
||||||
|
{ remove_skybox(viewer); });
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void remove_ibl_ffi(void *const viewer) {
|
FLUTTER_PLUGIN_EXPORT void remove_ibl_ffi(void *const viewer)
|
||||||
std::packaged_task<void()> lambda([=] { remove_ibl(viewer); });
|
{
|
||||||
|
std::packaged_task<void()> lambda([=]
|
||||||
|
{ remove_ibl(viewer); });
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_light_ffi(void *const viewer, uint8_t type, float colour,
|
void add_light_ffi(void *const viewer, uint8_t type, float colour,
|
||||||
float intensity, float posX, float posY, float posZ,
|
float intensity, float posX, float posY, float posZ,
|
||||||
float dirX, float dirY, float dirZ, bool shadows, void (*callback)(EntityId)) {
|
float dirX, float dirY, float dirZ, bool shadows, void (*callback)(EntityId))
|
||||||
std::packaged_task<EntityId()> lambda([=] {
|
{
|
||||||
|
std::packaged_task<EntityId()> lambda([=]
|
||||||
|
{
|
||||||
auto entity = add_light(viewer, type, colour, intensity, posX, posY, posZ, dirX,
|
auto entity = add_light(viewer, type, colour, intensity, posX, posY, posZ, dirX,
|
||||||
dirY, dirZ, shadows);
|
dirY, dirZ, shadows);
|
||||||
callback(entity);
|
callback(entity);
|
||||||
return entity;
|
return entity; });
|
||||||
});
|
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void remove_light_ffi(void *const viewer,
|
FLUTTER_PLUGIN_EXPORT void remove_light_ffi(void *const viewer,
|
||||||
EntityId entityId) {
|
EntityId entityId)
|
||||||
std::packaged_task<void()> lambda([=] { remove_light(viewer, entityId); });
|
{
|
||||||
|
std::packaged_task<void()> lambda([=]
|
||||||
|
{ remove_light(viewer, entityId); });
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void clear_lights_ffi(void *const viewer) {
|
FLUTTER_PLUGIN_EXPORT void clear_lights_ffi(void *const viewer)
|
||||||
std::packaged_task<void()> lambda([=] { clear_lights(viewer); });
|
{
|
||||||
|
std::packaged_task<void()> lambda([=]
|
||||||
|
{ clear_lights(viewer); });
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void remove_entity_ffi(void *const viewer,
|
FLUTTER_PLUGIN_EXPORT void remove_entity_ffi(void *const viewer,
|
||||||
EntityId asset, void (*callback)()) {
|
EntityId asset, void (*callback)())
|
||||||
std::packaged_task<void()> lambda([=] {
|
{
|
||||||
|
std::packaged_task<void()> lambda([=]
|
||||||
|
{
|
||||||
remove_entity(viewer, asset);
|
remove_entity(viewer, asset);
|
||||||
callback();
|
callback(); });
|
||||||
});
|
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void clear_entities_ffi(void *const viewer, void (*callback)()) {
|
FLUTTER_PLUGIN_EXPORT void clear_entities_ffi(void *const viewer, void (*callback)())
|
||||||
std::packaged_task<void()> lambda([=] {
|
{
|
||||||
|
std::packaged_task<void()> lambda([=]
|
||||||
|
{
|
||||||
clear_entities(viewer);
|
clear_entities(viewer);
|
||||||
callback();
|
callback(); });
|
||||||
});
|
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void set_camera_ffi(void *const viewer, EntityId asset,
|
FLUTTER_PLUGIN_EXPORT void set_camera_ffi(void *const viewer, EntityId asset,
|
||||||
const char *nodeName, void (*callback)(bool)) {
|
const char *nodeName, void (*callback)(bool))
|
||||||
|
{
|
||||||
std::packaged_task<bool()> lambda(
|
std::packaged_task<bool()> lambda(
|
||||||
[=] {
|
[=]
|
||||||
|
{
|
||||||
auto success = set_camera(viewer, asset, nodeName);
|
auto success = set_camera(viewer, asset, nodeName);
|
||||||
callback(success);
|
callback(success);
|
||||||
return success;
|
return success;
|
||||||
});
|
});
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void
|
FLUTTER_PLUGIN_EXPORT void
|
||||||
get_morph_target_name_ffi(void *sceneManager, EntityId asset,
|
get_morph_target_name_ffi(void *sceneManager, EntityId asset,
|
||||||
const char *meshName, char *const outPtr, int index, void (*callback)()) {
|
const char *meshName, char *const outPtr, int index, void (*callback)())
|
||||||
std::packaged_task<void()> lambda([=] {
|
{
|
||||||
|
std::packaged_task<void()> lambda([=]
|
||||||
|
{
|
||||||
get_morph_target_name(sceneManager, asset, meshName, outPtr, index);
|
get_morph_target_name(sceneManager, asset, meshName, outPtr, index);
|
||||||
callback();
|
callback(); });
|
||||||
});
|
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void
|
FLUTTER_PLUGIN_EXPORT void
|
||||||
get_morph_target_name_count_ffi(void *sceneManager, EntityId asset,
|
get_morph_target_name_count_ffi(void *sceneManager, EntityId asset,
|
||||||
const char *meshName, void (*callback)(int)) {
|
const char *meshName, void (*callback)(int))
|
||||||
std::packaged_task<int()> lambda([=] {
|
{
|
||||||
|
std::packaged_task<int()> lambda([=]
|
||||||
|
{
|
||||||
auto count = get_morph_target_name_count(sceneManager, asset, meshName);
|
auto count = get_morph_target_name_count(sceneManager, asset, meshName);
|
||||||
callback(count);
|
callback(count);
|
||||||
return count;
|
return count; });
|
||||||
});
|
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FLUTTER_PLUGIN_EXPORT void play_animation_ffi(void *const sceneManager,
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void play_animation_ffi(void *const sceneManager,
|
|
||||||
EntityId asset, int index,
|
EntityId asset, int index,
|
||||||
bool loop, bool reverse,
|
bool loop, bool reverse,
|
||||||
bool replaceActive,
|
bool replaceActive,
|
||||||
float crossfade) {
|
float crossfade)
|
||||||
std::packaged_task<void()> lambda([=] {
|
{
|
||||||
play_animation(sceneManager, asset, index, loop, reverse, replaceActive,
|
std::packaged_task<void()> lambda([=]
|
||||||
crossfade);
|
{ play_animation(sceneManager, asset, index, loop, reverse, replaceActive,
|
||||||
});
|
crossfade); });
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void set_animation_frame_ffi(void *const sceneManager,
|
FLUTTER_PLUGIN_EXPORT void set_animation_frame_ffi(void *const sceneManager,
|
||||||
EntityId asset,
|
EntityId asset,
|
||||||
int animationIndex,
|
int animationIndex,
|
||||||
int animationFrame) {
|
int animationFrame)
|
||||||
std::packaged_task<void()> lambda([=] {
|
{
|
||||||
set_animation_frame(sceneManager, asset, animationIndex, animationFrame);
|
std::packaged_task<void()> lambda([=]
|
||||||
});
|
{ set_animation_frame(sceneManager, asset, animationIndex, animationFrame); });
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void stop_animation_ffi(void *const sceneManager,
|
FLUTTER_PLUGIN_EXPORT void stop_animation_ffi(void *const sceneManager,
|
||||||
EntityId asset, int index) {
|
EntityId asset, int index)
|
||||||
|
{
|
||||||
std::packaged_task<void()> lambda(
|
std::packaged_task<void()> lambda(
|
||||||
[=] { stop_animation(sceneManager, asset, index); });
|
[=]
|
||||||
|
{ stop_animation(sceneManager, asset, index); });
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void get_animation_count_ffi(void *const sceneManager,
|
FLUTTER_PLUGIN_EXPORT void get_animation_count_ffi(void *const sceneManager,
|
||||||
EntityId asset,
|
EntityId asset,
|
||||||
void (*callback)(int)) {
|
void (*callback)(int))
|
||||||
|
{
|
||||||
std::packaged_task<int()> lambda(
|
std::packaged_task<int()> lambda(
|
||||||
[=] {
|
[=]
|
||||||
|
{
|
||||||
auto count = get_animation_count(sceneManager, asset);
|
auto count = get_animation_count(sceneManager, asset);
|
||||||
callback(count);
|
callback(count);
|
||||||
return count;
|
return count;
|
||||||
});
|
});
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void get_animation_name_ffi(void *const sceneManager,
|
FLUTTER_PLUGIN_EXPORT void get_animation_name_ffi(void *const sceneManager,
|
||||||
EntityId asset,
|
EntityId asset,
|
||||||
char *const outPtr,
|
char *const outPtr,
|
||||||
int index,
|
int index,
|
||||||
void (*callback)()) {
|
void (*callback)())
|
||||||
|
{
|
||||||
std::packaged_task<void()> lambda(
|
std::packaged_task<void()> lambda(
|
||||||
[=] {
|
[=]
|
||||||
|
{
|
||||||
get_animation_name(sceneManager, asset, outPtr, index);
|
get_animation_name(sceneManager, asset, outPtr, index);
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void set_post_processing_ffi(void *const viewer,
|
FLUTTER_PLUGIN_EXPORT void set_post_processing_ffi(void *const viewer,
|
||||||
bool enabled) {
|
bool enabled)
|
||||||
|
{
|
||||||
std::packaged_task<void()> lambda(
|
std::packaged_task<void()> lambda(
|
||||||
[=] { set_post_processing(viewer, enabled); });
|
[=]
|
||||||
|
{ set_post_processing(viewer, enabled); });
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void
|
FLUTTER_PLUGIN_EXPORT void
|
||||||
get_name_for_entity_ffi(void *const sceneManager, const EntityId entityId, void (*callback)(const char*)) {
|
get_name_for_entity_ffi(void *const sceneManager, const EntityId entityId, void (*callback)(const char *))
|
||||||
|
{
|
||||||
std::packaged_task<const char *()> lambda(
|
std::packaged_task<const char *()> lambda(
|
||||||
[=] {
|
[=]
|
||||||
|
{
|
||||||
auto name = get_name_for_entity(sceneManager, entityId);
|
auto name = get_name_for_entity(sceneManager, entityId);
|
||||||
callback(name);
|
callback(name);
|
||||||
return name;
|
return name;
|
||||||
});
|
});
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_morph_target_weights_ffi(void *const sceneManager,
|
void set_morph_target_weights_ffi(void *const sceneManager,
|
||||||
EntityId asset,
|
EntityId asset,
|
||||||
const char *const entityName,
|
|
||||||
const float *const morphData,
|
const float *const morphData,
|
||||||
int numWeights) {
|
int numWeights,
|
||||||
|
void (*callback)(bool))
|
||||||
|
{
|
||||||
std::packaged_task<void()> lambda(
|
std::packaged_task<void()> lambda(
|
||||||
[=] {
|
[=]
|
||||||
set_morph_target_weights(sceneManager, asset, entityName, morphData, numWeights);
|
{
|
||||||
|
auto result = set_morph_target_weights(sceneManager, asset, morphData, numWeights);
|
||||||
|
callback(result);
|
||||||
});
|
});
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_morph_animation_ffi(
|
FLUTTER_PLUGIN_EXPORT void set_bone_transform_ffi(
|
||||||
void *sceneManager,
|
|
||||||
EntityId asset,
|
|
||||||
const char *const entityName,
|
|
||||||
const float *const morphData,
|
|
||||||
const int *const morphIndices,
|
|
||||||
int numMorphTargets,
|
|
||||||
int numFrames,
|
|
||||||
float frameLengthInMs,
|
|
||||||
void (*callback)(bool)) {
|
|
||||||
std::packaged_task<bool()> lambda(
|
|
||||||
[=] {
|
|
||||||
auto success = set_morph_animation(sceneManager, asset, entityName, morphData, morphIndices, numMorphTargets, numFrames, frameLengthInMs);
|
|
||||||
callback(success);
|
|
||||||
return success;
|
|
||||||
});
|
|
||||||
auto fut = _rl->add_task(lambda);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void set_bone_transform_ffi(
|
|
||||||
void *sceneManager,
|
void *sceneManager,
|
||||||
EntityId asset,
|
EntityId asset,
|
||||||
const char *entityName,
|
const char *entityName,
|
||||||
const float *const transform,
|
const float *const transform,
|
||||||
const char *boneName,
|
const char *boneName,
|
||||||
void (*callback)(bool)) {
|
void (*callback)(bool))
|
||||||
|
{
|
||||||
std::packaged_task<bool()> lambda(
|
std::packaged_task<bool()> lambda(
|
||||||
[=] {
|
[=]
|
||||||
|
{
|
||||||
auto success = set_bone_transform(sceneManager, asset, entityName, transform, boneName);
|
auto success = set_bone_transform(sceneManager, asset, entityName, transform, boneName);
|
||||||
callback(success);
|
callback(success);
|
||||||
return success;
|
return success;
|
||||||
});
|
});
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void reset_to_rest_pose_ffi(void* const sceneManager, EntityId entityId) {
|
FLUTTER_PLUGIN_EXPORT void reset_to_rest_pose_ffi(void *const sceneManager, EntityId entityId)
|
||||||
|
{
|
||||||
std::packaged_task<void()> lambda(
|
std::packaged_task<void()> lambda(
|
||||||
[=] { return reset_to_rest_pose(sceneManager, entityId); });
|
[=]
|
||||||
|
{ return reset_to_rest_pose(sceneManager, entityId); });
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void add_bone_animation_ffi(
|
FLUTTER_PLUGIN_EXPORT void add_bone_animation_ffi(
|
||||||
void *sceneManager,
|
void *sceneManager,
|
||||||
EntityId asset,
|
EntityId asset,
|
||||||
const float *const frameData,
|
const float *const frameData,
|
||||||
@@ -563,25 +625,28 @@ FLUTTER_PLUGIN_EXPORT void add_bone_animation_ffi(
|
|||||||
const char **const meshNames,
|
const char **const meshNames,
|
||||||
int numMeshTargets,
|
int numMeshTargets,
|
||||||
float frameLengthInMs,
|
float frameLengthInMs,
|
||||||
bool isModelSpace) {
|
bool isModelSpace)
|
||||||
|
{
|
||||||
|
|
||||||
std::packaged_task<void()> lambda(
|
std::packaged_task<void()> lambda(
|
||||||
[=] {
|
[=]
|
||||||
|
{
|
||||||
add_bone_animation(sceneManager, asset, frameData, numFrames, boneName, meshNames, numMeshTargets, frameLengthInMs, isModelSpace);
|
add_bone_animation(sceneManager, asset, frameData, numFrames, boneName, meshNames, numMeshTargets, frameLengthInMs, isModelSpace);
|
||||||
});
|
});
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void ios_dummy_ffi() { Log("Dummy called"); }
|
FLUTTER_PLUGIN_EXPORT void ios_dummy_ffi() { Log("Dummy called"); }
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void create_geometry_ffi(void* const viewer, float* vertices, int numVertices, uint16_t* indices, int numIndices, int primitiveType, const char* materialPath, void (*callback)(EntityId) ) {
|
FLUTTER_PLUGIN_EXPORT void create_geometry_ffi(void *const viewer, float *vertices, int numVertices, uint16_t *indices, int numIndices, int primitiveType, const char *materialPath, void (*callback)(EntityId))
|
||||||
|
{
|
||||||
std::packaged_task<EntityId()> lambda(
|
std::packaged_task<EntityId()> lambda(
|
||||||
[=] {
|
[=]
|
||||||
|
{
|
||||||
auto entity = create_geometry(viewer, vertices, numVertices, indices, numIndices, primitiveType, materialPath);
|
auto entity = create_geometry(viewer, vertices, numVertices, indices, numIndices, primitiveType, materialPath);
|
||||||
callback(entity);
|
callback(entity);
|
||||||
return entity;
|
return entity;
|
||||||
});
|
});
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user