All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
softSelectHelper.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXRUSDMAYAGL_SOFT_SELECT_HELPER_H
25 #define PXRUSDMAYAGL_SOFT_SELECT_HELPER_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxrUsdMayaGL/api.h"
31 
32 #include "pxr/base/tf/hash.h"
33 
34 #include <maya/MColor.h>
35 #include <maya/MDagPath.h>
36 #include <maya/MRampAttribute.h>
37 #include <maya/MString.h>
38 
39 #include <unordered_map>
40 
41 
42 PXR_NAMESPACE_OPEN_SCOPE
43 
44 
58 {
59 public:
60  PXRUSDMAYAGL_API
62 
64  PXRUSDMAYAGL_API
65  void Reset();
66 
68  PXRUSDMAYAGL_API
69  void Populate();
70 
76  PXRUSDMAYAGL_API
77  bool GetWeight(const MDagPath& dagPath, float* weight) const;
78 
83  PXRUSDMAYAGL_API
84  bool GetFalloffColor(const MDagPath& dagPath, MColor* falloffColor) const;
85 
86 private:
87 
88  void _PopulateWeights();
89  void _PopulateSoftSelectColorRamp();
90 
91  struct _MDagPathHash {
92  inline size_t operator()(const MDagPath& dagPath) const {
93  return TfHash()(std::string(dagPath.fullPathName().asChar()));
94  }
95  };
96  typedef std::unordered_map<MDagPath, float, _MDagPathHash> _MDagPathsToWeights;
97 
98  _MDagPathsToWeights _dagPathsToWeight;
99  MColor _wireColor;
100  bool _populated;
101 };
102 
103 
104 PXR_NAMESPACE_CLOSE_SCOPE
105 
106 
107 #endif // PXRUSDMAYAGL_SOFT_SELECT_HELPER_H
PXRUSDMAYAGL_API bool GetWeight(const MDagPath &dagPath, float *weight) const
Returns true if dagPath is in the softSelection.
PXRUSDMAYAGL_API void Reset()
Clears the saved soft selection state.
Helper class to store soft (&quot;rich&quot;) selection state while computing render params for a frame...
Provides hash function on STL string types and other types.
Definition: hash.h:86
PXRUSDMAYAGL_API void Populate()
Repopulates soft selection state.
PXRUSDMAYAGL_API bool GetFalloffColor(const MDagPath &dagPath, MColor *falloffColor) const
Returns true if dagPath is in the softSelection.