src/gl/partrenderer.cpp

changeset 313
c24d87f64bed
parent 311
fab454611f9b
child 329
6d75fa09cc0c
equal deleted inserted replaced
312:2637134bc37c 313:c24d87f64bed
317 void PartRenderer::mousePressEvent(QMouseEvent* event) 317 void PartRenderer::mousePressEvent(QMouseEvent* event)
318 { 318 {
319 if (not this->frozen) { 319 if (not this->frozen) {
320 this->totalMouseMove = 0; 320 this->totalMouseMove = 0;
321 this->lastMousePosition = event->pos(); 321 this->lastMousePosition = event->pos();
322 this->lastClickTime = steady_clock::now();
322 } 323 }
323 } 324 }
324 325
325 void PartRenderer::mouseReleaseEvent(QMouseEvent* event) 326 void PartRenderer::mouseReleaseEvent(QMouseEvent* event)
326 { 327 {
327 if (not frozen and this->totalMouseMove < (2.0 / sqrt(2)) * 5.0) 328 using namespace std::chrono_literals;
328 { 329 if (true
330 and not frozen
331 and this->totalMouseMove < 50.0 / sqrt(2)
332 and (steady_clock::now() - this->lastClickTime) < 0.5s
333 ) {
329 for (RenderLayer* layer : this->activeRenderLayers) { 334 for (RenderLayer* layer : this->activeRenderLayers) {
330 layer->mouseClick(event); 335 layer->mouseClick(event);
331 } 336 }
332 this->update(); 337 this->update();
333 } 338 }
492 { 497 {
493 Q_ASSERT(not selection.contains({0})); 498 Q_ASSERT(not selection.contains({0}));
494 gl::setModelShaderSelectedObjects(&this->shaders, selection); 499 gl::setModelShaderSelectedObjects(&this->shaders, selection);
495 this->update(); 500 this->update();
496 } 501 }
502
503 glm::vec3 PartRenderer::cameraVector(const QPointF& point) const
504 {
505 const glm::vec3 p1 = this->unproject({point.x(), point.y(), 0});
506 const glm::vec3 p2 = this->unproject({point.x(), point.y(), 1});
507 return p2 - p1;
508 }

mercurial