예제 #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
  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;
    }
  }
예제 #3
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;
    }
  }