src/gl/partrenderer.cpp

changeset 86
4bec0525ef1b
parent 78
97c3ce5aa498
child 92
c438a7db7c52
--- a/src/gl/partrenderer.cpp	Wed Mar 18 17:11:23 2020 +0200
+++ b/src/gl/partrenderer.cpp	Thu Mar 19 21:06:06 2020 +0200
@@ -61,11 +61,7 @@
 		abort();
 	}
 	this->compiler->initialize();
-	this->compiler->build(this->model, this->documents, this->renderPreferences);
-	connect(this->model, &Model::dataChanged, [&]()
-	{
-		this->compiler->build(this->model, this->documents, this->renderPreferences);
-	});
+	connect(this->model, &Model::dataChanged, this, &PartRenderer::build);
 	this->initialized = true;
 	this->modelQuaternion = glm::angleAxis(glm::radians(30.0f), glm::vec3{-1, 0, 0});
 	this->modelQuaternion *= glm::angleAxis(glm::radians(225.0f), glm::vec3{-0, 1, 0});
@@ -112,6 +108,11 @@
 
 void PartRenderer::renderScene()
 {
+	if (this->needBuild)
+	{
+		this->compiler->build(this->model, this->documents, this->renderPreferences);
+		this->needBuild = false;
+	}
 	this->checkForGLErrors();
 	if (this->renderPreferences.lineAntiAliasing && this->renderPreferences.style != gl::RenderStyle::PickScene)
 	{
@@ -212,6 +213,11 @@
 {
 }
 
+void PartRenderer::build()
+{
+	this->needBuild = true;
+}
+
 void PartRenderer::renderVao(const gl::ArrayClass arrayClass)
 {
 	this->compiler->bindVertexArray(arrayClass);
@@ -370,7 +376,7 @@
 	this->renderPreferences = newPreferences;
 	if (mainColorChanged or backgroundColorChanged)
 	{
-		this->compiler->build(this->model, this->documents, this->renderPreferences);
+		this->build();
 		this->setupBackgroundColor();
 	}
 	emit this->renderPreferencesChanged();

mercurial