HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_Blend.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: GU_Blend.h (C++)
7  *
8  * COMMENTS: Functions for blending between details.
9  *
10  */
11 
12 
13  #ifndef __GU_BLEND_H__
14 #define __GU_BLEND_H__
15 
16 #include "GU_API.h"
17 #include <GA/GA_Names.h>
18 #include <GA/GA_Types.h>
19 #include <UT/UT_Array.h>
20 
21 class UT_StringRef;
22 class GU_Detail;
23 class GA_Attribute;
24 class GA_Group;
25 class GA_Range;
26 
27 enum class GU_VoxelBlend
28 {
29  None,
31  ByVoxelPos,
32  Advected
33 };
34 
35 enum class GU_MaskMode
36 {
37  None,
40 };
41 
42 namespace GU_Blend
43 {
45 {
50 };
51 template <typename T>
53 {
58 };
59 
61 {
63  bool myHasIdAttribMapping = false;
64  bool myIdAttribDataIdIsSame = false;
65 };
66 
67 struct MaskData
68 {
71  int mySource;
72 };
73 
74 /// This cache can be used to accelerate successive blends. However,
75 /// it is all references to *external* data.
76 /// It also does *NOT* detect if the id attribute names change, so the
77 /// caller is expected to clear the cache in that case.
79 {
80 public:
90 };
91 template <typename T>
93 {
94 public:
104 };
105 }
106 
107 /// If deleteUnmatched is true, points that don't have a match to interpolate with are deleted.
108 /// If deleteUnmatched is false but unmatchedGroupName is given (non-NULL), then these points
109 /// are instead put into a point group of the specified name.
110 /// Note that points of volume and VDB primitives are neither deleted nor put into the group.
111 GU_API void GUblend(
112  GU_Detail *dest, const GU_Detail *source, fpreal weight,
113  const char *pattern = "*", const UT_StringRef &ptidattr = GA_Names::id, const UT_StringRef &primidattr = GA_Names::name,
114  bool doslerp = true, bool usevforpinterp = false, float timestep = (1/24.0),
115  GU_VoxelBlend dovoxel = GU_VoxelBlend::None, GU_Blend::CachedItems *cached_items = NULL, const char *velname = "vel",
116  float advdt = 1, bool deleteUnmatched = false, const char *unmatchedGroupName = NULL);
117 
118 /// If deleteUnmatched is non-zero, points that have fewer than that many interpolation sources
119 /// are deleted from the output (or put into the specified group if unmatchedGroupName is not
120 /// NULL).
121 /// NOTE: Advected volume interpolation is necessarily linear; in that case, volweight is needed to determine
122 /// which detail to blend with and by how much.
123 GU_API void GUblend(
124  GU_Detail *dest, const GU_Detail *gdps[], const float *weights, int size, const GA_Group *group,
125  const char *pattern = "*", const UT_StringRef &ptidattr = GA_Names::id, const UT_StringRef &primidattr = GA_Names::name,
126  bool doslerp = true, GU_VoxelBlend dovoxel = GU_VoxelBlend::None, GU_Blend::CachedItems *cached_items = NULL,
127  bool is_differencing = true, bool dosparse = false,
128  float timestep = (1/24.0), const char *velname = "vel", float advdt = 1, fpreal volweight = 0,
129  int deleteUnmatched = 0, const char *unmatchedGroupName = NULL,
130  const GU_Blend::MaskData * mask_data = NULL,
131  float total = 1);
132 
133 /// Blend the attribute values for the given range, with an optional mapping to
134 /// different offsets in the second detail.
135 /// If set, the weights and mapping arrays should be at least as long as attrib0's offset
136 /// map (attrib0.getIndexMap().offsetSize()).
137 /// @{
138 GU_API void GUblendRange(
139  GA_Attribute &attrib0,
140  const GA_Attribute &attrib1,
141  const GA_Range &range0,
142  float weight,
143  const UT_Array<GA_Offset> *mapping);
144 
145 GU_API void GUblendRange(
146  GA_Attribute &attrib0,
147  const GA_Attribute &attrib1,
148  const GA_Range &range0,
149  const UT_Array<float> &weights,
150  const UT_Array<GA_Offset> *mapping);
151 /// @}
152 
153 /// Calculate the blend weight for an in-between shape given the channel weight
154 /// and a list of all in-between weights
156  float channel_weight,
157  const UT_Array<float> &inbetween_weights,
158  int inbetween_idx);
159 #endif
UT_Array< GA_Offset > myArrayOfOffsets
Definition: GU_Blend.h:62
Definition of a geometry attribute.
Definition: GA_Attribute.h:198
UT_Array< PerAttribData > * myVertexArrayOfPerAttribData
Definition: GU_Blend.h:83
UT_Array< PerMappingData > * myPtArrayOfPerMappingData
Definition: GU_Blend.h:84
UT_Array< UT_Array< int > > myArrayOfPageOffsets
Definition: GU_Blend.h:55
UT_Array< PerAttribDataT< T > > * myPtArrayOfPerAttribData
Definition: GU_Blend.h:95
UT_Array< PerAttribData > * myPtArrayOfPerAttribData
Definition: GU_Blend.h:81
UT_Array< UT_Array< std::pair< GA_PageNum, exint > > > myArrayOfPageStarts
Definition: GU_Blend.h:56
UT_Array< int64 > * myPrimListDataIds
Definition: GU_Blend.h:101
UT_Array< PerAttribDataT< T > > * myVertexArrayOfPerAttribData
Definition: GU_Blend.h:97
A range of elements in an index-map.
Definition: GA_Range.h:42
GA_API const UT_StringHolder name
UT_Array< UT_Array< int > > myArrayOfPageOffsets
Definition: GU_Blend.h:47
UT_Array< int64 > * myPrimListDataIds
Definition: GU_Blend.h:87
GU_API float GUgetInbetweenWeight(float channel_weight, const UT_Array< float > &inbetween_weights, int inbetween_idx)
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:803
UT_Array< UT_Array< std::pair< GA_PageNum, exint > > > myArrayOfPageStarts
Definition: GU_Blend.h:48
UT_Array< PerAttribData > * myPrimArrayOfPerAttribData
Definition: GU_Blend.h:82
GU_MaskMode myMode
Definition: GU_Blend.h:69
long long int64
Definition: SYS_Types.h:116
GU_MaskMode
Definition: GU_Blend.h:35
#define GU_API
Definition: GU_API.h:14
GLushort pattern
Definition: glad.h:2583
GA_API const UT_StringHolder id
GU_VoxelBlend
Definition: GU_Blend.h:27
UT_Array< int64 > * myPtTopoDataIds
Definition: GU_Blend.h:86
UT_Array< PerMappingData > * myPtArrayOfPerMappingData
Definition: GU_Blend.h:98
GU_API void GUblendRange(GA_Attribute &attrib0, const GA_Attribute &attrib1, const GA_Range &range0, float weight, const UT_Array< GA_Offset > *mapping)
GLsizeiptr size
Definition: glcorearb.h:664
int64 * myPtIdDataId
Definition: GU_Blend.h:88
UT_Array< int64 > myArrayOfDataId
Definition: GU_Blend.h:49
fpreal64 fpreal
Definition: SYS_Types.h:277
UT_Array< int64 > myArrayOfDataId
Definition: GU_Blend.h:57
UT_StringRef myAttribName
Definition: GU_Blend.h:70
int64 * myPrimIdDataId
Definition: GU_Blend.h:89
UT_Array< PerAttribDataT< T > > * myPrimArrayOfPerAttribData
Definition: GU_Blend.h:96
UT_Array< UT_Array< T > > myArrayOfDeltas
Definition: GU_Blend.h:54
UT_Array< int64 > * myPtTopoDataIds
Definition: GU_Blend.h:100
UT_Array< UT_Array< float > > myArrayOfDeltas
Definition: GU_Blend.h:46
GU_API void GUblend(GU_Detail *dest, const GU_Detail *source, fpreal weight, const char *pattern="*", const UT_StringRef &ptidattr=GA_Names::id, const UT_StringRef &primidattr=GA_Names::name, bool doslerp=true, bool usevforpinterp=false, float timestep=(1/24.0), GU_VoxelBlend dovoxel=GU_VoxelBlend::None, GU_Blend::CachedItems *cached_items=NULL, const char *velname="vel", float advdt=1, bool deleteUnmatched=false, const char *unmatchedGroupName=NULL)
UT_Array< PerMappingData > * myPrimArrayOfPerMappingData
Definition: GU_Blend.h:85
UT_Array< PerMappingData > * myPrimArrayOfPerMappingData
Definition: GU_Blend.h:99