예제 #1
0
  ToolResponse runMoveEvent (const ViewPointingEvent& e) {
    auto minDistance = [this] (const Intersection& intersection) -> bool {
      const float d = this->radiusEdit.doubleValue () * this->stepWidthFactor;
      return glm::distance (this->previousPosition, intersection.position ()) > d;
    };

    if (e.primaryButton ()) {
      if (e.modifiers () == Qt::ShiftModifier) {
        SketchPathIntersection intersection;

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

          if (minDistance (intersection)) {
            this->previousPosition = intersection.position ();
            this->mesh             = &intersection.mesh ();

            this->mesh->smoothPath ( intersection.path ()
                                   , PrimSphere ( intersection.position ()
                                                , this->radiusEdit.doubleValue () )
                                   , 1
                                   , this->smoothEffect
                                   , this->self->mirrorDimension () );
          }
        }
      }
      else if (this->mesh) {
        SketchMeshIntersection intersection;
        const unsigned int     numExcludedLastPaths = this->self->hasMirror () ? 2 : 1;
              bool             considerHeight       = true;

        if (this->self->intersectsScene (e, intersection, numExcludedLastPaths) == false) {
          const Camera&   camera = this->self->state ().camera ();
          const PrimRay   ray    = camera.ray (e.ivec2 ());
          const PrimPlane plane  = PrimPlane ( this->previousPosition
                                             , DimensionUtil::vector (camera.primaryDimension ()) );
          float t;
          if (IntersectionUtil::intersects (ray, plane, &t)) {
            intersection.update (t, ray.pointAt (t), plane.normal (), *this->mesh);
            considerHeight = false;
          }
        }

        if (intersection.isIntersection () && minDistance (intersection)) {
          this->previousPosition = intersection.position ();

          this->mesh->addSphere ( false
                                , intersection.position ()
                                , this->newSpherePosition (considerHeight, intersection)
                                , this->radiusEdit.doubleValue ()
                                , this->self->mirrorDimension () );
        }
      }
      return ToolResponse::Redraw;
    }
    else {
      return this->runCursorUpdate (e.ivec2 ());
    }
  }
예제 #2
0
파일: sculpt.cpp 프로젝트: AMDmi3/dilay
  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;
    }
  }
예제 #3
0
  ToolResponse runPressEvent (const ViewPointingEvent& e) {
    auto setupOnIntersection = [this] (const SketchMeshIntersection& intersection) {
      this->cursor.enable   ();
      this->cursor.position (intersection.position ());

      this->self->snapshotSketchMeshes ();

      this->mesh             = &intersection.mesh ();
      this->previousPosition = intersection.position ();
    };

    if (e.primaryButton ()) {
      if (e.modifiers () == Qt::ShiftModifier) {
        SketchPathIntersection intersection;
        if (this->self->intersectsScene (e, intersection)) {
          setupOnIntersection (intersection);

          this->mesh->smoothPath ( intersection.path ()
                                 , PrimSphere ( intersection.position ()
                                              , this->radiusEdit.doubleValue () )
                                 , 1
                                 , this->smoothEffect
                                 , this->self->mirrorDimension () );
        }
      }
      else {
        SketchMeshIntersection intersection;
        if (this->self->intersectsScene (e, intersection)) {
          setupOnIntersection (intersection);

          this->mesh->addSphere ( true
                                , intersection.position ()
                                , this->newSpherePosition (true, intersection)
                                , this->radiusEdit.doubleValue ()
                                , this->self->mirrorDimension () );
        }
        else {
          this->cursor.disable ();
        }
      }
      return ToolResponse::Redraw;
    }
    else {
      return ToolResponse::None;
    }
  }
예제 #4
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;
 }
예제 #5
0
파일: sculpt.cpp 프로젝트: AMDmi3/dilay
  bool carvelikeStroke ( const ViewPointingEvent& e, bool useRecentOctree
                       , const std::function <void ()>* toggle )
  {
    if (this->updateBrushAndCursorByIntersection (e, useRecentOctree)) {
      const float defaultIntesity = this->brush.intensity ();

      this->brush.intensity (defaultIntesity * e.intensity ());

      if (toggle && e.modifiers () == Qt::ShiftModifier) {
        (*toggle) ();
        this->sculpt ();
        (*toggle) ();
      }
      else {
        this->sculpt ();
      }

      this->brush.intensity (defaultIntesity);
      return true;
    }
    else {
      return false;
    }
  }
예제 #6
0
파일: sculpt.cpp 프로젝트: AMDmi3/dilay
  ToolResponse runPointingEvent (const ViewPointingEvent& e) {
    if (e.releaseEvent ()) {
      if (e.primaryButton ()) {
        this->brush.resetPointOfAction ();

        if (this->sculpted == false) {
          this->self->state ().history ().dropSnapshot ();
        }
      }
      this->cursor.enable ();
      return ToolResponse::Redraw;
    }
    else {
      if (e.pressEvent () && e.primaryButton ()) {
        this->self->snapshotWingedMeshes ();
        this->sculpted = false;
      }

      if (this->self->runSculptPointingEvent (e)) {
        this->sculpted = true;
      }
      return ToolResponse::Redraw;
    }
  }
예제 #7
0
파일: sculpt.cpp 프로젝트: AMDmi3/dilay
  bool draglikeStroke (const ViewPointingEvent& e, ToolUtilMovement& movement) {
    if (e.primaryButton () == false) {
      this->updateCursorByIntersection (e);
      return false;
    }
    else if (this->brush.hasPosition ()) {
      const glm::vec3 oldBrushPos = this->brush.position ();

      if ( movement.move (e, false)
        && this->brush.updatePointOfAction ( movement.position ()
                                           , movement.position () - oldBrushPos ) )
      {
        this->sculpt ();
        return true;
      }
      else {
        return false;
      }
    }
    else {
      return false;
    }
  }
예제 #8
0
파일: sculpt.cpp 프로젝트: AMDmi3/dilay
 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;
   }
 }