src/gl/partrenderer.cpp

changeset 313
c24d87f64bed
parent 311
fab454611f9b
child 329
6d75fa09cc0c
--- a/src/gl/partrenderer.cpp	Fri Jul 01 16:46:43 2022 +0300
+++ b/src/gl/partrenderer.cpp	Fri Jul 01 23:48:27 2022 +0300
@@ -319,13 +319,18 @@
 	if (not this->frozen) {
 		this->totalMouseMove = 0;
 		this->lastMousePosition = event->pos();
+		this->lastClickTime = steady_clock::now();
 	}
 }
 
 void PartRenderer::mouseReleaseEvent(QMouseEvent* event)
 {
-	if (not frozen and this->totalMouseMove < (2.0 / sqrt(2)) * 5.0)
-	{
+	using namespace std::chrono_literals;
+	if (true
+		and not frozen
+		and this->totalMouseMove < 50.0 / sqrt(2)
+		and (steady_clock::now() - this->lastClickTime) < 0.5s
+	) {
 		for (RenderLayer* layer : this->activeRenderLayers) {
 			layer->mouseClick(event);
 		}
@@ -494,3 +499,10 @@
 	gl::setModelShaderSelectedObjects(&this->shaders, selection);
 	this->update();
 }
+
+glm::vec3 PartRenderer::cameraVector(const QPointF& point) const
+{
+	const glm::vec3 p1 = this->unproject({point.x(), point.y(), 0});
+	const glm::vec3 p2 = this->unproject({point.x(), point.y(), 1});
+	return p2 - p1;
+}

mercurial