Example #1
0
  void updateCursorByIntersection (const ViewPointingEvent& e) {
    WingedFaceIntersection intersection;

    if (this->self->intersectsScene (e, intersection)) {
      this->cursor.enable   ();
      this->cursor.position (intersection.position ());
    }
    else {
      this->cursor.disable ();
    }
  }
Example #2
0
 ToolResponse runReleaseEvent (const ViewPointingEvent& e) {
   if (e.primaryButton ()) {
     WingedFaceIntersection intersection;
     if (this->self->intersectsScene (e, intersection)) {
       Scene& scene = this->self->state ().scene ();
       this->self->snapshotWingedMeshes ();
       scene.deleteMesh (intersection.mesh ());
       return ToolResponse::Redraw;
     }
   }
   return ToolResponse::None;
 }
Example #3
0
  void setupCursor () {
    assert (this->brush.radius () > 0.0f);

    WingedFaceIntersection intersection;
    if (this->self->intersectsScene (this->self->cursorPosition (), intersection)) {
      this->cursor.enable   ();
      this->cursor.position (intersection.position ());
    }
    else {
      this->cursor.disable ();
    }
    this->cursor.radius (this->brush.radius ());

    this->self->runSetupCursor (this->cursor);
  }
Example #4
0
  void mousePressEvent (State& state, const QMouseEvent& event) {
    if (event.button () == Qt::MiddleButton) {
      this->oldPos = ViewUtil::toIVec2 (event);

      if (event.modifiers () == Qt::ControlModifier) {
        Camera& cam = state.camera ();
        WingedFaceIntersection intersection;
        if (state.scene ().intersects (cam.ray (ViewUtil::toIVec2 (event)), intersection)) {
          cam.set ( intersection.position ()
                  , cam.position () - intersection.position ()
                  , cam.up () );
          state.mainWindow ().mainWidget ().glWidget ().update ();
        }
      }
    }
  }
Example #5
0
  bool updateBrushAndCursorByIntersection (const ViewPointingEvent& e, bool useRecentOctree) {
    WingedFaceIntersection intersection;

    if (this->self->intersectsScene (e, intersection)) {
      this->cursor.enable   ();
      this->cursor.position (intersection.position ());

      if (e.primaryButton ()) {
        this->brush.mesh (&intersection.mesh ());

        if (useRecentOctree) {
          Intersection octreeIntersection;
          if (this->self->intersectsRecentOctree (e, octreeIntersection)) {
            return this->brush.updatePointOfAction ( octreeIntersection.position ()
                                                   , octreeIntersection.normal () );
          }
          else {
            return this->brush.updatePointOfAction ( intersection.position ()
                                                   , intersection.normal () );
          }
        }
        else {
          return this->brush.updatePointOfAction ( intersection.position ()
                                                 , intersection.normal () );
        }
      }
      else {
        return false;
      }
    }
    else {
      this->cursor.disable ();
      return false;
    }
  }
Example #6
0
 bool initializeDraglikeStroke (const ViewPointingEvent& e, ToolUtilMovement& movement) {
   if (e.primaryButton ()) {
     WingedFaceIntersection intersection;
     if (this->self->intersectsScene (e, intersection)) {
       this->brush.mesh (&intersection.mesh ());
       this->brush.setPointOfAction (intersection.position (), intersection.normal ());
       
       this->cursor.disable ();
       movement.resetPosition (intersection.position ());
       return true;
     }
     else {
       this->cursor.enable ();
       this->brush.resetPointOfAction ();
       return false;
     }
   }
   else {
     this->cursor.enable ();
     this->brush.resetPointOfAction ();
     return false;
   }
 }
Example #7
0
 bool intersects (const PrimRay& ray, WingedFaceIntersection& intersection) {
   this->forEachMesh ([this, &ray, &intersection] (WingedMesh& m) {
     m.intersects (ray, intersection);
   });
   return intersection.isIntersection ();
 }