HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SOP_PrimVOP.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021
3  * Side Effects Software Inc. All rights reserved.
4  *
5  * Redistribution and use of Houdini Development Kit samples in source and
6  * binary forms, with or without modification, are permitted provided that the
7  * following conditions are met:
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. The name of Side Effects Software may not be used to endorse or
11  * promote products derived from this software without specific prior
12  * written permission.
13  *
14  * THIS SOFTWARE IS PROVIDED BY SIDE EFFECTS SOFTWARE `AS IS' AND ANY EXPRESS
15  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
17  * NO EVENT SHALL SIDE EFFECTS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
20  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
23  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  *----------------------------------------------------------------------------
26  */
27 
28 #ifndef __SOP_PrimVOP__
29 #define __SOP_PrimVOP__
30 
31 #include <SOP/SOP_Node.h>
32 
33 #include <VEX/VEX_PodTypes.h>
34 template <VEX_Precision PREC> class CVEX_ContextT;
36 
37 #include <VOP/VOP_CodeGenerator.h>
39 
40 class CVEX_RunData;
41 class OP_Caller;
42 
43 namespace HDK_Sample {
44 class SOP_PrimVOP : public SOP_Node
45 {
46 public:
47  SOP_PrimVOP(OP_Network *net, const char *, OP_Operator *entry);
48  ~SOP_PrimVOP() override;
49 
50  static OP_Node *myConstructor(OP_Network *net, const char *name,
51  OP_Operator *entry);
53 
54  /// Overriding these are what allow us to contain VOPs
56  const char *getChildType() const override;
57  OP_OpTypeId getChildTypeID() const override;
58 
60  bool hasVexShaderParameter(const char *parm_name) override;
61 
62  /// We need special alerts now that we contain VOPs.
63  void opChanged(OP_EventType reason, void *data=0) override;
64 
65  /// Code generation variables.
66  bool evalVariableValue(
68  int index,
69  int thread) override;
70 
71  // Add virtual overload that delegates to the super class to avoid
72  // shadow warnings.
74  fpreal &v,
75  int i,
76  int thread) override
77  { return SOP_Node::evalVariableValue(v,i,thread); }
78 
79  static const char *theChildTableName;
80 
81 protected:
83 
84  void executeVex(int argc, char **argv,
85  fpreal t, OP_Caller &opcaller);
86 
88  CVEX_RunData &rundata,
89  int argc, char **argv,
90  int *primid, int n,
91  fpreal t);
92 
94  { return evalInt("vexsrc", 0, t); }
96  { evalString(s, "script", 0, t); }
97 
99  { evalString(path, "shoppath", 0, t); }
100 
101  /// VOP and VEX functions
103  bool is_child_call=false) override;
104  void addNode(OP_Node *node, int notify=1,
105  int explicitly=1) override;
108  OP_NodeInfoParms &parms) override;
109 
110  void buildScript(UT_String &script, fpreal t);
111 
112  /// Every operator that has a VOP code generator needs to define
113  /// this method in order for Parameter VOP changes to be reflected
114  /// in the VOP network's parameter interface.
115  ///
116  /// This method requires <VOP/VOP_CodeGenerator.h>
117  /// and <VOP/VOP_ExportedParmsManager.h> to be included.
119  {
120  // Check if the spare parameter templates
121  // are out-of-date.
122  if (getVopCodeGenerator()
124  .requiresUpdate(0.0))
125  {
126  // Call into the code generator to update
127  // the spare parameter templates.
131  }
132  }
133 
135 };
136 } // End HDK_Sample namespace
137 
138 #endif
139 
GLdouble s
Definition: glew.h:1390
bool evalVariableValue(fpreal &val, int index, int thread) override
GLuint const GLchar * name
Definition: glew.h:1814
OP_ERROR cookMySop(OP_Context &context) override
Definition: SOP_PrimVOP.C:144
void addNode(OP_Node *node, int notify=1, int explicitly=1) override
Definition: SOP_PrimVOP.C:771
bool evalVariableValue(UT_String &value, int index, int thread) override
Code generation variables.
Definition: SOP_PrimVOP.C:716
GLuint index
Definition: glew.h:1814
const char * getChildType() const override
Definition: SOP_PrimVOP.C:743
VOP_CodeGenerator * getVopCodeGenerator() override
Definition: SOP_PrimVOP.C:731
void opChanged(OP_EventType reason, void *data=0) override
We need special alerts now that we contain VOPs.
Definition: SOP_PrimVOP.C:755
SOP_PrimVOP(OP_Network *net, const char *, OP_Operator *entry)
Definition: SOP_PrimVOP.C:118
UT_ErrorSeverity
Definition: UT_Error.h:25
Parameters for OP_Node::getInfoText()/OP_Node::getNodeSpecificInfoText()
void updateOwnerSpareParmLayout(bool allow_update_while_loading=false)
Update the owner network's spare parameter layout.
const GLdouble * v
Definition: glew.h:1391
static const char * theChildTableName
Definition: SOP_PrimVOP.h:79
void ensureSpareParmsAreUpdatedSubclass() override
Definition: SOP_PrimVOP.h:118
static PRM_Template myTemplateList[]
Definition: SOP_PrimVOP.h:52
VOP_ExportedParmsManager * exportedParmsManager() const
Return the exported parameters manager.
void SCRIPT(UT_String &s, fpreal t)
Definition: SOP_PrimVOP.h:95
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
void evalString(UT_String &val, int pi, int vi, fpreal t) const
void finishedLoadingNetwork(bool is_child_call=false) override
VOP and VEX functions.
Definition: SOP_PrimVOP.C:764
void SHOPPATH(UT_String &path, fpreal t)
Definition: SOP_PrimVOP.h:98
bool hasVexShaderParameter(const char *parm_name) override
Definition: SOP_PrimVOP.C:737
DEP_MicroNode & eventMicroNode(OP_EventType e)
bool evalVariableValue(fpreal &v, int i, int thread) override
Definition: SOP_PrimVOP.h:73
GLsizei n
Definition: glew.h:4040
OP_OpTypeId
Definition: OP_OpTypeId.h:18
*Note that the tasks the is the thread number *for the or if it s being executed by a non pool thread(this *can happen in cases where the whole pool is occupied and the calling *thread contributes to running the work load).**Thread pool.Have fun
void executeVex(int argc, char **argv, fpreal t, OP_Caller &opcaller)
Definition: SOP_PrimVOP.C:190
Per-run data for CVEX execution.
Definition: CVEX_Context.h:35
GLsizei const GLchar *const * path
Definition: glew.h:6461
void getNodeSpecificInfoText(OP_Context &context, OP_NodeInfoParms &parms) override
Definition: SOP_PrimVOP.C:779
static OP_Node * myConstructor(OP_Network *net, const char *name, OP_Operator *entry)
Definition: SOP_PrimVOP.C:112
fpreal64 fpreal
Definition: SYS_Types.h:277
OP_EventType
Definition: OP_Value.h:22
exint evalInt(int pi, int vi, fpreal t) const
OP_OpTypeId getChildTypeID() const override
Definition: SOP_PrimVOP.C:749
OP_OperatorFilter * getOperatorFilter() override
Overriding these are what allow us to contain VOPs.
Definition: SOP_PrimVOP.C:725
Call VEX from C++.
Definition: CVEX_Context.h:175
void processVexBlock(CVEX_Context &context, CVEX_RunData &rundata, int argc, char **argv, int *primid, int n, fpreal t)
Definition: SOP_PrimVOP.C:499
GLsizei const GLfloat * value
Definition: glew.h:1849
VOP_CodeGenerator myCodeGenerator
Definition: SOP_PrimVOP.h:134
GLdouble GLdouble t
Definition: glew.h:1398
int VEXSRC(fpreal t)
Definition: SOP_PrimVOP.h:93
void buildScript(UT_String &script, fpreal t)
Definition: SOP_PrimVOP.C:666