more refactoring
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
|
||||
|
||||
#if __APPLE__
|
||||
#include "TargetConditionals.h"
|
||||
#endif
|
||||
@@ -6,35 +8,31 @@
|
||||
#pragma comment(lib, "Ws2_32.lib")
|
||||
#endif
|
||||
|
||||
#include <filament/Camera.h>
|
||||
#include <filament/SwapChain.h>
|
||||
#include <backend/DriverEnums.h>
|
||||
#include <backend/platforms/OpenGLPlatform.h>
|
||||
#include <math/mat4.h>
|
||||
#include <utils/EntityManager.h>
|
||||
#include <utils/Panic.h>
|
||||
#include <utils/Systrace.h>
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <backend/platforms/PlatformWebGL.h>
|
||||
#include <emscripten/emscripten.h>
|
||||
#include <emscripten/bind.h>
|
||||
#include <emscripten.h>
|
||||
#include <emscripten/html5.h>
|
||||
#include <emscripten/threading.h>
|
||||
#include <emscripten/val.h>
|
||||
#include <filament/webgl/WebEngine.h>
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#include <filament/Box.h>
|
||||
#include <filament/Camera.h>
|
||||
#include <filament/ColorGrading.h>
|
||||
#include <filament/Engine.h>
|
||||
|
||||
#include <filament/Options.h>
|
||||
#include <filament/Renderer.h>
|
||||
#include <filament/View.h>
|
||||
|
||||
#include <filament/IndexBuffer.h>
|
||||
#include <filament/IndirectLight.h>
|
||||
#include <filament/LightManager.h>
|
||||
#include <filament/Material.h>
|
||||
#include <filament/MaterialInstance.h>
|
||||
#include <filament/RenderableManager.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <streambuf>
|
||||
#include <sstream>
|
||||
#include <istream>
|
||||
#include <fstream>
|
||||
#include <filesystem>
|
||||
#include <mutex>
|
||||
#include <iomanip>
|
||||
#include <unordered_set>
|
||||
#include <filament/Scene.h>
|
||||
#include <filament/Skybox.h>
|
||||
#include <filament/TransformManager.h>
|
||||
#include <filament/VertexBuffer.h>
|
||||
|
||||
#include "Log.hpp"
|
||||
|
||||
@@ -70,13 +68,32 @@ namespace thermion
|
||||
}
|
||||
|
||||
mRenderable[swapChain] = swapChainViews;
|
||||
|
||||
// Keep track of the swapchains, so we can iterate them in the render method.
|
||||
bool found = false;
|
||||
for (auto existingSwapChain : mSwapChains) {
|
||||
if (existingSwapChain == swapChain) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
mSwapChains.push_back(swapChain);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RenderTicker::render(uint64_t frameTimeInNanos)
|
||||
{
|
||||
std::lock_guard lock(mMutex);
|
||||
|
||||
mSceneManager->update();
|
||||
// Update all animation managers
|
||||
for (auto animationManager : mAnimationManagers) {
|
||||
if (animationManager) { // Check for nullptr just in case
|
||||
animationManager->update(frameTimeInNanos * 1e-9);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (auto swapChain : mSwapChains)
|
||||
{
|
||||
@@ -99,5 +116,19 @@ namespace thermion
|
||||
#endif
|
||||
}
|
||||
|
||||
void RenderTicker::addAnimationManager(AnimationManager* animationManager) {
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
mAnimationManagers.push_back(animationManager);
|
||||
}
|
||||
|
||||
} // namespace thermion
|
||||
void RenderTicker::removeAnimationManager(AnimationManager* animationManager) {
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
auto it = std::find(mAnimationManagers.begin(), mAnimationManagers.end(), animationManager);
|
||||
if (it != mAnimationManagers.end()) {
|
||||
mAnimationManagers.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
RenderTicker::~RenderTicker() {}
|
||||
|
||||
} // namespace thermion
|
||||
Reference in New Issue
Block a user