48 namespace HDK_Sample {
69 using namespace HDK_Sample;
77 mySopId(sop->getUniqueId()),
78 myOldNumPts(oldnumpts),
111 static PRM_Name sopOriginName(
"origin",
"Origin");
112 static PRM_Name sopDirectionName(
"direction",
"Direction");
113 static PRM_Name sopRadiusName(
"radius",
"Radius");
114 static PRM_Name sopColorName(
"color",
"Color");
115 static PRM_Name sopAlphaName(
"alpha",
"Alpha");
116 static PRM_Name sopOperationName(
"operation",
"Operation");
117 static PRM_Name sopEventName(
"event",
"Event");
118 static PRM_Name sopClearAllName(
"clearall",
"Clear All");
126 static PRM_Name sopOperationMenuNames[] =
143 static PRM_Name sopEventMenuNames[] =
146 PRM_Name(
"active",
"Active Stroke"),
244 if(myData.size() == 0)
250 else if(myNumPts != npts)
257 int event = getEvent(t);
261 myOldData.setSize(0);
262 myOldNumPts = myNumPts;
270 fpreal radius = getRadius(t);
271 fpreal radius2 = radius * radius;
274 int operation = getOperation(t);
279 for(
exint i = 0; i < myData.size(); ++i)
280 table[myData(i).myPtNum] = i;
282 for(
exint i = 0; i < myOldData.size(); ++i)
283 oldtable[myOldData(i).myPtNum] = i;
301 fpreal parlen2 = dot_p_dir * dot_p_dir;
302 if (parlen2 <= 0 || perp.
length2() >= radius2 * parlen2)
309 auto it = table.find(ptnum);
311 if (it == table.end())
315 table[ptnum] = index;
321 auto oldit = oldtable.find(ptnum);
322 if (oldit == oldtable.end())
325 index = myOldData.append(d);
326 oldtable[ptnum] = index;
334 d.
myRed = alpha * color.
x() + one_minus_alpha * d.
myRed;
341 d.
myRed *= one_minus_alpha;
343 d.
myBlue *= one_minus_alpha;
357 myOldData.setSize(0);
377 for (
exint i = 0; i < myData.size(); ++i)
384 if (input_handle.isValid())
389 r += one_minus_alpha * f.
x();
390 g += one_minus_alpha * f.
y();
391 b += one_minus_alpha * f.
z();
398 if (myData.size() > 0)
408 const char *path_prefix,
417 const char *ext = saveflags.
getBinary() ?
"bpaint" :
"paint";
418 path.
sprintf(
"%s%s.%s", path_prefix, (
const char *)
getName(), ext);
423 out.
write(&myNumPts, 1,
true);
426 out.write(&n, 1,
true);
428 for (
exint i = 0; i <
n; ++i)
447 if(strcmp(ext,
"bpaint") == 0 || strcmp(ext,
"paint") == 0)
451 myOldData.setSize(0);
453 if(!is.
read(&myNumPts))
459 for(
exint i = 0; i <
n; ++i)
509 for (
exint i = 0; i < myData.size(); ++i)
510 table[myData(i).myPtNum] = i;
517 if(it != table.end())
521 myData(it->second) = d;
558 myOldData.setSize(0);
constexpr SYS_FORCE_INLINE T length2() const noexcept
virtual int open(UT_IStream &is, UT_WorkBuffer &pathname)
#define GEO_STD_ATTRIB_DIFFUSE
PRM_API const PRM_Type PRM_CALLBACK
static int clearAllStatic(void *op, int, fpreal time, const PRM_Template *)
PRM_API const PRM_Type PRM_STRING
UT_OStream & write(const char_type *str, int64 count)
GA_Attribute * addFloatTuple(GA_AttributeOwner owner, GA_AttributeScope scope, const UT_StringHolder &name, int tuple_size, const GA_Defaults &defaults=GA_Defaults(0.0), const UT_Options *creation_args=0, const GA_AttributeOptions *attribute_options=0, GA_Storage storage=GA_STORE_REAL32, const GA_ReuseStrategy &reuse=GA_ReuseStrategy())
IMF_EXPORT IMATH_NAMESPACE::V3f direction(const IMATH_NAMESPACE::Box2i &dataWindow, const IMATH_NAMESPACE::V2f &pixelPosition)
GLsizei const GLchar *const * path
UT_Vector3T< float > UT_Vector3
static PRM_SpareData * getGroupSelectButton(GA_GroupType group_type, const char *group_type_parm=NULL, int input_index=0, PRM_SpareData *merge_spare_data=NULL, const char *assoc_groups=NULL, GroupSelectAsOrdered ordered=GroupSelectAsOrdered::AUTO, const char *use_name_attr=nullptr, const char *select_script=nullptr)
~SOP_CustomBrush() override
constexpr SYS_FORCE_INLINE T & z() noexcept
UT_API UT_UndoManager * UTgetUndoManager()
virtual void forceRecook(bool evensmartcache=true)
PRM_API const PRM_Type PRM_ORD
int64 getMemoryUsage(bool inclusive=false) const
SYS_FORCE_INLINE const char * buffer() const
GLboolean GLboolean GLboolean GLboolean a
void addToMemoryUsage(int64 k)
SOP_CustomBrush(OP_Network *net, const char *name, OP_Operator *op)
PRM_API PRM_Default PRMpointOneDefaults[]
bool addOperator(OP_Operator *op, std::ostream *err=nullptr)
SYS_FORCE_INLINE UT_Vector3 getPos3(GA_Offset ptoff) const
The ptoff passed is the point offset.
PRM_API const PRM_Type PRM_XYZ_J
static PRM_ChoiceList pointGroupMenu
void addError(int code, const char *msg=0)
exint GA_Size
Defines the bit width for index and offset types in GA.
PRM_API const PRM_Type PRM_RGB_J
GA_RWHandleT< UT_Vector3F > GA_RWHandleV3
bool load(UT_IStream &is, const char *extension, const char *path=0) override
bool load(UT_IStream &is, const char *extension, const char *path) override
OP_ERROR save(std::ostream &os, const OP_SaveFlags &flags, const char *path_prefix, const UT_String &name_override=UT_String()) override
void addToUndoBlock(UT_Undo *undo)
void updateData(exint numpts, UT_Array< SOP_CustomBrushData > &data)
OP_ERROR duplicateChangedSource(unsigned idx, OP_Context &ctx, int *changed=0, bool force=false)
Only duplicates the source if the source has changed since the last call to this method.
const GU_Detail * inputGeo(int index, OP_Context &)
OP_ERROR cookMySop(OP_Context &context) override
exint read(bool *array, exint sz=1)
fpreal64 dot(const CE_VectorT< T > &a, const CE_VectorT< T > &b)
OP_ERROR cookInputGroups(OP_Context &context, int alone=0) override
OP_ERROR cookInputPointGroups(OP_Context &context, const GA_PointGroup *&group, bool alone=false, bool do_selection=true, int parm_index=0, int group_type_index=-1, bool allow_reference=true, bool ordered=false, bool detached=true, int input_index=0)
See cookInputPrimitiveGroups.
GLfloat GLfloat GLfloat alpha
GLuint const GLchar * name
PRM_API PRM_Name PRMgroupName
GLboolean GLboolean GLboolean b
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
PRM_API const PRM_Type PRM_FLT_J
GLenum GLenum GLsizei void * table
void setManagesDataIDs(bool onOff)
static OP_Node * myConstructor(OP_Network *, const char *, OP_Operator *)
SOP_UndoCustomBrushData(SOP_CustomBrush *sop, GA_Size oldnumpts, GA_Size numpts, UT_Array< SOP_CustomBrushData > &olddata, UT_Array< SOP_CustomBrushData > &data)
int sprintf(const char *fmt,...) SYS_PRINTF_CHECK_ATTRIBUTE(2
SYS_FORCE_INLINE GA_Index pointIndex(GA_Offset offset) const
Given a point's data offset, return its index.
const GA_Attribute * findFloatTuple(GA_AttributeOwner owner, GA_AttributeScope scope, const UT_StringRef &name, int min_size=1, int max_size=-1) const
PRM_API PRM_Default PRMoneDefaults[]
#define GA_FOR_ALL_GROUP_PTOFF(gdp, grp, ptoff)
virtual int close(UT_IStream &is)
int willAcceptUndoAddition()
SYS_FORCE_INLINE const UT_String & getName() const
void newSopOperator(OP_OperatorTable *table)
static OP_Node * lookupNode(int unique_id, bool include_proxy=false)
SYS_FORCE_INLINE UT_StorageMathFloat_t< T > normalize() noexcept
void resetChangedSourceFlags()
constexpr SYS_FORCE_INLINE T & y() noexcept
static PRM_Template myTemplateList[]
SYS_FORCE_INLINE GA_Offset pointOffset(GA_Index index) const
Given a point's index (in append order), return its data offset.
OP_ERROR save(std::ostream &os, const OP_SaveFlags &flags, const char *pathPrefix, const UT_String &name_override=UT_String()) override
SYS_FORCE_INLINE GA_Size getNumPoints() const
Return the number of points.
constexpr SYS_FORCE_INLINE T & x() noexcept