HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GEO_Transform.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: GEO_Transform.h (GU Library, C++)
7  *
8  */
9 
10 // TODO should there be a class or namespace or anything, or just totally stand
11 // alone functions?
12 
13 #ifndef __GEO_Transform_h__
14 #define __GEO_Transform_h__
15 
16 #include "GEO_API.h"
17 
19 #include <GA/GA_Names.h>
20 
21 #include "GEO_Delta.h"
22 
24  UT_Array<GA_RWHandleV3> &attribs,
25  UT_Array<GA_RWHandleV3D> &doubleattribs,
26  UT_Array<GA_RWHandleM4> &m4attribs,
27  UT_Array<GA_RWHandleM4D> &m4dattribs,
28  const char *attribpattern);
29 
30 // Computes on which side of the symmetry plane a given position lies. The
31 // side in the direction of the normal is 1, the opposite side is -1, and,
32 // right on the plane is 0.
34  const GEO_Detail::SoftSymmetryParms &symmetry,
35  const UT_Vector3 pos);
36 
38  const GA_AttributeTransformer &attribs,
40  GA_AttributeOwner owner,
43  bool just_P,
44  int keep_length,
45  GEO_Delta *geodelta,
46  const char *attribpattern = NULL)
47 {
48  if (geodelta)
49  {
50  GEO_Detail &detail = static_cast<GEO_Detail &>(attribs.getDetail());
51  if (owner == GA_ATTRIB_POINT && (!attribpattern || GA_Names::P.multiMatch(attribpattern)))
52  {
53  geodelta->beginPointPositionChange(detail, offset);
54  if (UTverify_cast<GA_ATINumeric*>(detail.getP())->getStorage() == GA_STORE_REAL64)
55  {
56  GA_RWHandleV3D pd(detail.getP());
57  pd.set(offset, pd.get(offset) * ctx64.xform());
58  }
59  else
60  detail.setPos3(offset, detail.getPos3(offset) * ctx32.xform());
61  geodelta->endChange();
62  }
63 
64  if (!just_P && attribs.entries() > 0)
65  {
66  if (owner == GA_ATTRIB_POINT)
67  geodelta->beginPointAttributeChange(detail, offset);
68  else if (owner == GA_ATTRIB_VERTEX)
69  geodelta->beginVertexAttributeChange(detail, offset);
70  else if (owner == GA_ATTRIB_PRIMITIVE)
71  geodelta->beginPrimitiveAttributeChange(*detail.getGEOPrimitive(offset));
72  attribs.transform(offset, ctx32, ctx64);
73  geodelta->endChange();
74  }
75  }
76  else
77  {
78  if (attribs.entries() == 0)
79  return;
80  attribs.transform(offset, ctx32, ctx64);
81  }
82 }
83 
84 // prepares matx
85 int GEO_API
86 GEOcomputeSoftXform(float dist2, const GEO_Detail::LocalXformContext *local,
87  const UT_XformOrder &order,
88  float tx, float ty, float tz,
89  float rx, float ry, float rz,
90  float sx, float sy, float sz,
91  float s_xy, float s_xz, float s_yz,
92  float px, float py, float pz,
93  float prx, float pry, float prz,
94  const GEO_Rolloff *rolloff,
95  UT_Matrix4 &matx, float *falloff);
96 
97 template<typename T>
99  static constexpr T value() { return 0; }
100 };
101 
102 template<>
104  static constexpr fpreal32 value() { return SYS_FTOLERANCE; }
105 };
106 
107 template<>
109  static constexpr fpreal64 value() { return 1e-14; }
110 };
111 
112 template<typename T>
113 inline T GEO_API
115 {
118  return f;
119 }
120 
122  GA_RWHandleV3D &doublep);
123 
124 void GEO_API GEOupdatePointNormals(GEO_Detail &gdp, GEO_Delta *geodelta);
125 #endif
126 
SYS_FORCE_INLINE void setPos3(GA_Offset ptoff, const UT_Vector3 &P)
Set P from a UT_Vector3.
Definition: GA_Detail.h:207
void GEO_API GEOgetFloatOrDoubleP(GEO_Detail &detail, GA_RWHandleV3 &floatp, GA_RWHandleV3D &doublep)
void GEO_API GEOupdatePointNormals(GEO_Detail &gdp, GEO_Delta *geodelta)
virtual void endChange()=0
GA_Detail & getDetail() const
Return the bound detail.
Class to pass transforms to GA_AttributeTransformer.
GA_Attribute * getP()
Convenience method to access the P attribute.
Definition: GA_Detail.h:163
static constexpr fpreal64 value()
GA_API const UT_StringHolder P
SYS_FORCE_INLINE UT_Vector3 getPos3(GA_Offset ptoff) const
The ptoff passed is the point offset.
Definition: GA_Detail.h:174
3D Vector class.
void transform(const GA_Range &range, Transform< fpreal32 > &m) const
int GEO_API GEOcomputeSoftXform(float dist2, const GEO_Detail::LocalXformContext *local, const UT_XformOrder &order, float tx, float ty, float tz, float rx, float ry, float rz, float sx, float sy, float sz, float s_xy, float s_xz, float s_yz, float px, float py, float pz, float prx, float pry, float prz, const GEO_Rolloff *rolloff, UT_Matrix4 &matx, float *falloff)
A string map of attributes to ease backward compatibility In the GB/GEO/GU library code would often p...
SYS_FORCE_INLINE GEO_Primitive * getGEOPrimitive(GA_Offset primoff)
Definition: GEO_Detail.h:1119
void GEO_API GEOxformElement(const GA_AttributeTransformer &attribs, GA_Offset offset, GA_AttributeOwner owner, GA_AttributeTransformer::Transform< fpreal32 > &ctx32, GA_AttributeTransformer::Transform< fpreal64 > &ctx64, bool just_P, int keep_length, GEO_Delta *geodelta, const char *attribpattern=NULL)
Definition: GEO_Transform.h:37
GA_Size GA_Offset
Definition: GA_Types.h:617
GLfloat f
Definition: glcorearb.h:1925
int GEO_API GEOcomputeSymmetrySide(const GEO_Detail::SoftSymmetryParms &symmetry, const UT_Vector3 pos)
double fpreal64
Definition: SYS_Types.h:192
GLintptr offset
Definition: glcorearb.h:664
#define GEO_API
Definition: GEO_API.h:10
static constexpr fpreal32 value()
virtual void beginPointPositionChange(const GA_Detail &gdp, GA_Offset pt)=0
const UT_Matrix4T< FLOAT_T > & xform() const
static constexpr T value()
Definition: GEO_Transform.h:99
T GEO_API GEOconditionScale(T f)
IFDmantra py
Definition: HDK_Image.dox:266
GA_AttributeOwner
Definition: GA_Types.h:33
SYS_FORCE_INLINE void set(GA_Offset off, const T &val) const
Definition: GA_Handle.h:320
virtual void beginPointAttributeChange(const GEO_Detail &gdp, GA_Offset pt)=0
exint entries() const
Return the number of attributes which will be transformed.
#define SYS_FTOLERANCE
Definition: SYS_Types.h:203
virtual void beginPrimitiveAttributeChange(const GEO_Primitive &prim)=0
virtual void beginVertexAttributeChange(const GEO_Detail &gdp, GA_Offset vtx)=0
bool GEO_API GEOgetAttributeList(const GA_AttributeDict &dict, UT_Array< GA_RWHandleV3 > &attribs, UT_Array< GA_RWHandleV3D > &doubleattribs, UT_Array< GA_RWHandleM4 > &m4attribs, UT_Array< GA_RWHandleM4D > &m4dattribs, const char *attribpattern)
float fpreal32
Definition: SYS_Types.h:191
Class to efficiently transform multiple attributes.