diff --git a/macos/include/FilamentViewer.hpp b/macos/include/FilamentViewer.hpp index d5839605..b61fee05 100644 --- a/macos/include/FilamentViewer.hpp +++ b/macos/include/FilamentViewer.hpp @@ -127,17 +127,17 @@ namespace polyvox { const ResourceLoaderWrapper* const _resourceLoaderWrapper; - Scene* _scene; - View* _view; - Engine* _engine; + Scene* _scene = nullptr; + View* _view = nullptr; + Engine* _engine = nullptr; // a default camera that we add to every scene - Camera* _mainCamera; + Camera* _mainCamera = nullptr; - Renderer* _renderer; - RenderTarget* _rt; - Texture* _rtColor; - Texture* _rtDepth; + Renderer* _renderer = nullptr; + RenderTarget* _rt = nullptr; + Texture* _rtColor = nullptr; + Texture* _rtDepth = nullptr; SwapChain* _swapChain = nullptr; diff --git a/macos/include/PolyvoxFilamentApi.h b/macos/include/FlutterFilamentApi.h similarity index 100% rename from macos/include/PolyvoxFilamentApi.h rename to macos/include/FlutterFilamentApi.h diff --git a/macos/include/PolyvoxFilamentFFIApi.h b/macos/include/FlutterFilamentFFIApi.h similarity index 100% rename from macos/include/PolyvoxFilamentFFIApi.h rename to macos/include/FlutterFilamentFFIApi.h diff --git a/macos/include/PolyvoxFilamentPlugin.h b/macos/include/FlutterFilamentPlugin.h similarity index 100% rename from macos/include/PolyvoxFilamentPlugin.h rename to macos/include/FlutterFilamentPlugin.h diff --git a/macos/include/SwiftPolyvoxFilamentPlugin-Bridging-Header.h b/macos/include/SwiftFlutterFilamentPlugin-Bridging-Header.h similarity index 100% rename from macos/include/SwiftPolyvoxFilamentPlugin-Bridging-Header.h rename to macos/include/SwiftFlutterFilamentPlugin-Bridging-Header.h diff --git a/macos/src/AssetManager.cpp b/macos/src/AssetManager.cpp index 0825fb63..5e3b8825 100644 --- a/macos/src/AssetManager.cpp +++ b/macos/src/AssetManager.cpp @@ -257,15 +257,17 @@ FilamentAsset* AssetManager::getAssetByEntityId(EntityId entityId) { void AssetManager::updateAnimations() { - auto now = high_resolution_clock::now(); RenderableManager &rm = _engine->getRenderableManager(); for (auto& asset : _assets) { + std::vector completed; int index = 0; for(auto& anim : asset.mAnimations) { + + auto now = high_resolution_clock::now(); auto elapsed = float(std::chrono::duration_cast(now - anim.mStart).count()) / 1000.0f; diff --git a/macos/src/FilamentViewer.cpp b/macos/src/FilamentViewer.cpp index 1c52304e..876a4b99 100644 --- a/macos/src/FilamentViewer.cpp +++ b/macos/src/FilamentViewer.cpp @@ -701,6 +701,7 @@ namespace polyvox _swapChain = nullptr; Log("Swapchain destroyed."); } + _engine->flushAndWait(); } void FilamentViewer::clearAssets() @@ -990,22 +991,22 @@ namespace polyvox cam.lookAt(eye, target, upward); } - // TODO - this was an experiment but probably useful to keep for debugging - // if pixelBuffer is provided, we will copy the framebuffer into the pixelBuffer. - if (pixelBuffer) - { - auto pbd = Texture::PixelBufferDescriptor( - pixelBuffer, size_t(1024 * 768 * 4), - Texture::Format::RGBA, - Texture::Type::BYTE, nullptr, callback, data); + // // TODO - this was an experiment but probably useful to keep for debugging + // // if pixelBuffer is provided, we will copy the framebuffer into the pixelBuffer. + // if (pixelBuffer) + // { + // auto pbd = Texture::PixelBufferDescriptor( + // pixelBuffer, size_t(1024 * 768 * 4), + // Texture::Format::RGBA, + // Texture::Type::BYTE, nullptr, callback, data); - _renderer->beginFrame(_swapChain, 0); - _renderer->render(_view); - _renderer->readPixels(0, 0, 1024, 768, std::move(pbd)); - _renderer->endFrame(); - } - else - { + // _renderer->beginFrame(_swapChain, 0); + // _renderer->render(_view); + // _renderer->readPixels(0, 0, 1024, 768, std::move(pbd)); + // _renderer->endFrame(); + // } + // else + // { // Render the scene, unless the renderer wants to skip the frame. if (_renderer->beginFrame(_swapChain, frameTimeInNanos)) { @@ -1014,9 +1015,10 @@ namespace polyvox } else { + // std::cout << "Skipped" << std::endl; // skipped frame } - } + // } } void FilamentViewer::updateViewportAndCameraProjection( diff --git a/macos/src/PolyvoxFilamentApi.cpp b/macos/src/FlutterFilamentApi.cpp similarity index 100% rename from macos/src/PolyvoxFilamentApi.cpp rename to macos/src/FlutterFilamentApi.cpp diff --git a/macos/src/PolyvoxFilamentFFIApi.cpp b/macos/src/FlutterFilamentFFIApi.cpp similarity index 99% rename from macos/src/PolyvoxFilamentFFIApi.cpp rename to macos/src/FlutterFilamentFFIApi.cpp index ccf46382..1795d9ba 100644 --- a/macos/src/PolyvoxFilamentFFIApi.cpp +++ b/macos/src/FlutterFilamentFFIApi.cpp @@ -77,7 +77,9 @@ public: void doRender() { render(_viewer, 0, nullptr, nullptr, nullptr); - _renderCallback(_renderCallbackOwner); + if(_renderCallback) { + _renderCallback(_renderCallbackOwner); + } } void setFrameIntervalInMilliseconds(float frameIntervalInMilliseconds) {