ai_operator.h
Go to the documentation of this file.
1 // Copyright 2020 Autodesk, Inc. All rights reserved.
2 //
3 // Use of this software is subject to the terms of the Autodesk license
4 // agreement provided at the time of installation or download, or which
5 // otherwise accompanies this software in either electronic or hard copy form.
6 
12 #pragma once
13 
14 #include "ai_nodes.h"
15 #include "ai_version.h"
16 #include "ai_matrix.h"
17 #include "ai_api.h"
18 
19 // Forward declarations
20 struct AtNode;
21 struct AtCookContext;
22 
55 typedef bool (*AtOpCleanupChildData)(void* child_data);
56 
57 AI_API bool AiOpSetTarget(AtUniverse* universe, AtNode* node);
58 AI_API AtNode* AiOpGetTarget(const AtUniverse* universe);
59 
60 AI_API AtArray* AiOpGetInputs(AtNode* op);
61 AI_API bool AiOpLink(AtNode* from, AtNode* to, int index = -1);
62 AI_API bool AiOpUnlinkInputByIndex(AtNode* to, unsigned int index);
63 AI_API bool AiOpUnlink(AtNode* from, AtNode* to);
64 
65 AI_API void AiOpSetChildData(AtNode* op, void* child_data = NULL, AtOpCleanupChildData cleanup = NULL);
66 
67 AI_API bool AiOpMatchNodeSelection(AtNode* node, AtString selection, bool relative = true, AtNode* target = NULL);
68 
69 AI_API AtNode* AiOpCookContextGetCookScope(AtCookContext* cook_context);
70 
71 // old API (assuming default universe) is deprecated
73 inline AI_DEPRECATED bool AiOpSetTarget(AtNode* node) { return AiOpSetTarget(NULL, node); }
74 inline AI_DEPRECATED AtNode* AiOpGetTarget() { return AiOpGetTarget(NULL); }
76 
93 typedef bool (*AtOpInit)(AtNode* op, void** user_data);
94 
107 typedef bool (*AtOpCleanup)(AtNode* op, void* user_data);
108 
139 typedef bool (*AtOpCook)(AtNode* node, AtNode* op, void* child_data, void* user_data, const AtArray* matching_params, AtCookContext* cook_context);
140 
151 typedef bool (*AtOpPostCook)(AtNode* op, void* user_data);
152 
163 {
164  AtOpInit Init;
165  AtOpCleanup Cleanup;
166  AtOpCook Cook;
167  AtOpPostCook PostCook;
168 };
169 
176 typedef int (*AtOpFuncPtr)(AtOperatorNodeMethods* methods);
177 
179 #define AI_OPERATOR_COMMON_NODE_METHODS \
180 node_parameters; \
181 static AtCommonMethods ai_common_mtds = { \
182  NULL, \
183  NULL, \
184  Parameters, \
185  NULL, \
186  NULL, \
187  NULL \
188 };
189 
190 #define AI_OPERATOR_NODE_EXPORT_METHODS(tag) \
191 AI_OPERATOR_COMMON_NODE_METHODS \
192 operator_init; \
193 operator_cleanup; \
194 operator_cook; \
195 operator_post_cook; \
196 static AtOperatorNodeMethods ai_op_mtds = { \
197  OperatorInit, \
198  OperatorCleanup, \
199  OperatorCook, \
200  OperatorPostCook \
201 }; \
202 static AtNodeMethods ai_node_mtds = { \
203  &ai_common_mtds, \
204  &ai_op_mtds \
205 }; \
206 const AtNodeMethods* tag = &ai_node_mtds;
207 
208 #define AI_OPERATOR_NODE_INTERNAL_METHODS(tag) \
209 AI_INSTANCE_COMMON_METHODS \
210 static AtNodeMethods ai_node_internal_mtds = { \
211  &ai_common_mtds, \
212  NULL \
213 }; \
214 const AtNodeMethods* tag = &ai_node_internal_mtds;
215 
216 #define operator_init \
217 static bool OperatorInit(AtNode* op, void** user_data)
218 
219 #define operator_cleanup \
220 static bool OperatorCleanup(AtNode* op, void* user_data)
221 
222 #define operator_cook \
223 static bool OperatorCook(AtNode* node, AtNode* op, void* child_data, void* user_data, const AtArray* matching_params, AtCookContext* cook_context)
224 
225 #define operator_post_cook \
226 static bool OperatorPostCook(AtNode* op, void* user_data)
227 
228 /*\}*/
bool(* AtOpCleanup)(AtNode *op, void *user_data)
Operator cleanup method.
Definition: ai_operator.h:107
AI_API bool AiOpUnlink(AtNode *from, AtNode *to)
Unlink connected operators.
Definition: ai_operator.cpp:211
This represents a universe in Arnold.
int(* AtOpFuncPtr)(AtOperatorNodeMethods *methods)
Operator function pointer entry-point symbol.
Definition: ai_operator.h:176
bool(* AtOpCook)(AtNode *node, AtNode *op, void *child_data, void *user_data, const AtArray *matching_params, AtCookContext *cook_context)
Operator cook method which operates on the cooked node.
Definition: ai_operator.h:139
This represents a node in Arnold.
AtNode struct and methods.
Arnold String allows for fast string comparisons.
Definition: ai_string.h:46
Cleanup method for child data which is passed to other operators.
Definition: ai_operator.h:162
AI_API bool AiOpUnlinkInputByIndex(AtNode *to, unsigned int index)
Unlink an input connection on an operator for a given index.
Definition: ai_operator.cpp:164
AI_API bool AiOpMatchNodeSelection(AtNode *node, AtString selection, bool relative=true, AtNode *target=NULL)
Check if a node, including its name and parameters, match a given selection expression.
Definition: ai_operator.cpp:288
bool(* AtOpPostCook)(AtNode *op, void *user_data)
Operator post cook method which is called once per operator instance after all the cook calls for all...
Definition: ai_operator.h:151
DLL export prefix for API functions (necessary for multi-platform development)
Version number information and checking of backwards-compatibility.
AI_API bool AiOpSetTarget(AtUniverse *universe, AtNode *node)
Set the target operator in a given Arnold universe.
Definition: ai_operator.cpp:35
bool(* AtOpInit)(AtNode *op, void **user_data)
Operator init method.
Definition: ai_operator.h:93
AI_API bool AiOpLink(AtNode *from, AtNode *to, int index=-1)
Connect an operator to a given input index on an operator.
Definition: ai_operator.cpp:102
AI_API AtNode * AiOpGetTarget(const AtUniverse *universe)
Get the target operator node in a given universe, if any.
Definition: ai_operator.cpp:68
AI_API AtArray * AiOpGetInputs(AtNode *op)
Get operator nodes connected to the inputs on a given operator node.
Definition: ai_operator.cpp:89
AI_API void AiOpSetChildData(AtNode *op, void *child_data=NULL, AtOpCleanupChildData cleanup=NULL)
Set child data on an operator.
Definition: ai_operator.cpp:24
AI_API AtNode * AiOpCookContextGetCookScope(AtCookContext *cook_context)
Get the cook scope which is represented by the node that the operator graph is connected to...
Definition: ai_operator.cpp:312
Matrix math type and methods.

© 2020 Autodesk, Inc. · All rights reserved · www.arnoldrenderer.com