Basic mutability framework
This commit is contained in:
@@ -19,13 +19,14 @@ InspectorView::~InspectorView()
|
||||
{
|
||||
}
|
||||
|
||||
void InspectorView::beginUpdate()
|
||||
Job InspectorView::beginUpdate()
|
||||
{
|
||||
co_return;
|
||||
}
|
||||
|
||||
void InspectorView::update()
|
||||
Job InspectorView::update()
|
||||
{
|
||||
|
||||
co_return;
|
||||
}
|
||||
|
||||
void InspectorView::commitUpdate()
|
||||
|
||||
@@ -13,8 +13,8 @@ public:
|
||||
InspectorView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &createInfo);
|
||||
virtual ~InspectorView();
|
||||
|
||||
virtual void beginUpdate() override;
|
||||
virtual void update() override;
|
||||
virtual Job beginUpdate() override;
|
||||
virtual Job update() override;
|
||||
virtual void commitUpdate() override;
|
||||
|
||||
virtual void prepareRender() override;
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "Asset/AssetRegistry.h"
|
||||
#include "Scene/Actor/CameraActor.h"
|
||||
#include "Scene/Components/CameraComponent.h"
|
||||
#include "Scene/Components/MyComponent.h"
|
||||
#include "Scene/Components/MyOtherComponent.h"
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
@@ -28,18 +30,23 @@ Seele::SceneView::SceneView(Gfx::PGraphics graphics, PWindow owner, const Viewpo
|
||||
AssetRegistry::importFile("C:\\Users\\Dynamitos\\TestSeeleProject\\Assets\\Ely\\Ely.fbx");
|
||||
AssetRegistry::importFile("C:\\Users\\Dynamitos\\TestSeeleProject\\Assets\\Cube\\cube.obj");
|
||||
AssetRegistry::importFile("C:\\Users\\Dynamitos\\TestSeeleProject\\Assets\\Plane\\plane.fbx");
|
||||
srand(time(NULL));
|
||||
for(uint32 i = 0; i < 100; ++i)
|
||||
{
|
||||
PPrimitiveComponent ayaka = new PrimitiveComponent(AssetRegistry::findMesh("Ayaka"));
|
||||
ayaka->addWorldTranslation(Vector(((float)rand() / RAND_MAX) * 100, 0, ((float)rand()/RAND_MAX) * 100));
|
||||
ayaka->setWorldScale(Vector(10, 10, 10));
|
||||
scene->addPrimitiveComponent(ayaka);
|
||||
}
|
||||
|
||||
PPrimitiveComponent ayaka = new PrimitiveComponent(AssetRegistry::findMesh("Ayaka"));
|
||||
ayaka->addWorldTranslation(Vector(0, 0, 0));
|
||||
ayaka->setWorldScale(Vector(10, 10, 10));
|
||||
scene->addPrimitiveComponent(ayaka);
|
||||
|
||||
PPrimitiveComponent plane = new PrimitiveComponent(AssetRegistry::findMesh("plane"));
|
||||
plane->setWorldScale(Vector(100, 100, 100));
|
||||
scene->addPrimitiveComponent(plane);
|
||||
|
||||
PMyComponent myComp = new MyComponent();
|
||||
PMyOtherComponent myOtherComp = new MyOtherComponent();
|
||||
PActor actor = new Actor();
|
||||
actor->setRootComponent(myComp);
|
||||
myComp->addChildComponent(myOtherComp);
|
||||
scene->addActor(actor);
|
||||
scene->start();
|
||||
|
||||
PRenderGraphResources resources = new RenderGraphResources();
|
||||
depthPrepass.setResources(resources);
|
||||
@@ -59,13 +66,16 @@ Seele::SceneView::~SceneView()
|
||||
{
|
||||
}
|
||||
|
||||
void SceneView::beginUpdate()
|
||||
Job SceneView::beginUpdate()
|
||||
{
|
||||
scene->tick(Gfx::currentFrameDelta);
|
||||
co_await scene->beginUpdate(Gfx::currentFrameDelta);
|
||||
co_return;
|
||||
}
|
||||
|
||||
void SceneView::update()
|
||||
Job SceneView::update()
|
||||
{
|
||||
co_await scene->commitUpdate();
|
||||
co_return;
|
||||
}
|
||||
|
||||
void SceneView::commitUpdate()
|
||||
|
||||
@@ -13,8 +13,8 @@ class SceneView : public View
|
||||
public:
|
||||
SceneView(Gfx::PGraphics graphics, PWindow owner, const ViewportCreateInfo &createInfo);
|
||||
~SceneView();
|
||||
virtual void beginUpdate() override;
|
||||
virtual void update() override;
|
||||
virtual Job beginUpdate() override;
|
||||
virtual Job update() override;
|
||||
virtual void commitUpdate() override;
|
||||
|
||||
virtual void prepareRender() override;
|
||||
|
||||
@@ -13,8 +13,8 @@ public:
|
||||
virtual ~View();
|
||||
|
||||
// These are called from the view thread, and handle updating game data
|
||||
virtual void beginUpdate() = 0;
|
||||
virtual void update() = 0;
|
||||
virtual Job beginUpdate() = 0;
|
||||
virtual Job update() = 0;
|
||||
// End frame is called with a lock, so it is safe to write to shared memory
|
||||
virtual void commitUpdate() = 0;
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ MainJob Window::render()
|
||||
co_await windowView->updateFinished;
|
||||
windowView->updateFinished.reset();
|
||||
{
|
||||
std::unique_lock lock(windowView->workerMutex);
|
||||
std::scoped_lock lock(windowView->workerMutex);
|
||||
windowView->view->prepareRender();
|
||||
}
|
||||
windowView->view->render();
|
||||
@@ -78,7 +78,7 @@ Job Window::viewWorker(size_t viewIndex)
|
||||
windowView->view->beginUpdate();
|
||||
windowView->view->update();
|
||||
{
|
||||
std::unique_lock lock(windowView->workerMutex);
|
||||
std::scoped_lock lock(windowView->workerMutex);
|
||||
windowView->view->commitUpdate();
|
||||
}
|
||||
//std::cout << "Update completed" << std::endl;
|
||||
|
||||
@@ -41,7 +41,7 @@ void WindowManager::notifyWindowClosed(PWindow window)
|
||||
windows.remove(windows.find(window));
|
||||
if(windows.empty())
|
||||
{
|
||||
std::unique_lock lock(windowsLock);
|
||||
std::scoped_lock lock(windowsLock);
|
||||
windowsCV.notify_all();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user