HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_EdgeSlide.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: SOP Library (C++)
7  *
8  * COMMENTS: Interface for computing sliding of edges.
9  */
10 
11 #ifndef __GU_EdgeSlide_h__
12 #define __GU_EdgeSlide_h__
13 
14 #include "GU_API.h"
15 #include "GU_Detail.h"
16 #include <UT/UT_Map.h>
17 #include <UT/UT_Set.h>
18 
19 class GU_RayIntersect;
20 
22 {
30 };
31 
33 {
34 public:
35  GU_SlideData(const GU_Detail &geo);
36 
37  // start sliding in response to dragging on a point
38  bool startSlidingPoint(GU_SlideMode mode, GA_Index idx,
39  const UT_Set<GA_Index> &sel, const UT_Vector3 &orig,
40  const UT_Vector3 &dir, const UT_Vector3 &nml,
41  const UT_Matrix4D &to_world);
42 
43  // start sliding in response to dragging on a primitive
44  bool startSlidingPrimitive(GU_SlideMode mode, GA_Index idx,
45  const UT_Set<GA_Index> &sel, const UT_Vector3 &orig,
46  const UT_Vector3 &dir, const UT_Vector3 &nml,
47  const UT_Matrix4D &to_world);
48 
49  // start sliding in response to dragging on an edge
50  bool startSlidingEdge(GU_SlideMode mode, GA_Index idx0, GA_Index idx1,
51  const UT_Set<std::pair<GA_Index, GA_Index> > &sel, const UT_Vector3 &orig,
52  const UT_Vector3 &dir, const UT_Vector3 &nml,
53  const UT_Matrix4D &to_world);
54 
55  // return edits and snapping resulting from drag
56  bool getSlidePositions(UT_Map<GA_Index, UT_Vector3> &edit_pos,
57  UT_Map<GA_Index, GA_Index> &snapped, const UT_Vector3 &orig,
58  const UT_Vector3 &dir);
59 
60  // finish sliding in response to ending a drag
61  void endSliding();
62 
63  // returns the slide surface
64  const GU_Detail *getGeo() const { return myGeo.get(); }
65 
66  // support for providing visual feedback
68  { return myUnusedEdges; }
70  { return myProfileEdges; }
71 
72 private:
73  GU_RayIntersect *getRayIntersect();
74 
75  void setGrip(GU_SlideMode mode, const UT_Vector3 &grip,
76  const UT_Vector3 &nml, const UT_Matrix4D &to_local);
77 
78  void recordPoint(GA_Index idx);
79 
80  void setSnapped(UT_Map<GA_Index, GA_Index> &snapped,
81  GA_Index idx, GA_Index goal) const;
82 
83  struct SlideEdge
84  {
85  SlideEdge(const UT_Vector3 &c, const UT_Vector3 &p0, const UT_Vector3 &p1, GA_Index s0, GA_Index s1)
86  : myPosC(c), myPos0(p0), myPos1(p1), mySnap0(s0), mySnap1(s1) {}
87 
88  UT_Vector3 myPosC;
89  UT_Vector3 myPos0;
90  UT_Vector3 myPos1;
91  GA_Index mySnap0;
92  GA_Index mySnap1;
93  };
94 
96  //UT_Map<GA_Index, UT_Set<GA_Index> > mySnappedPointsLookup;
97  UT_UniquePtr<GU_RayIntersect> myRayIntersect;
98 
99  bool myIsSliding;
100  GA_Index myGripPt0;
101  GA_Index myGripPt1;
102  fpreal myGripU;
103  GU_SlideMode myMode;
104  UT_Vector3 myGrip; // world space grip position
105  UT_Vector3 myNormal; // world space normal of slide plane
106  UT_Matrix4D myXform; // xform to object space
107 
110  UT_Set<std::pair<GA_Index, GA_Index> > myUnusedEdges;
111  UT_Set<std::pair<GA_Index, GA_Index> > myProfileEdges;
112 };
113 
114 #endif
Definition: UT_Set.h:58
Unsorted map container.
Definition: UT_Map.h:107
GU_SlideMode
Definition: GU_EdgeSlide.h:21
const UT_Set< std::pair< GA_Index, GA_Index > > & getUnusedEdges() const
Definition: GU_EdgeSlide.h:67
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
const UT_Set< std::pair< GA_Index, GA_Index > > & getProfileEdges() const
Definition: GU_EdgeSlide.h:69
#define GU_API
Definition: GU_API.h:14
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
Definition: GA_Types.h:640
GLenum mode
Definition: glcorearb.h:99
fpreal64 fpreal
Definition: SYS_Types.h:277
const GU_Detail * getGeo() const
Definition: GU_EdgeSlide.h:64