ai_operator.h
Go to the documentation of this file.
1// Copyright 2023 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
20struct AtNode;
21struct AtCookContext;
22
55typedef bool (*AtOpCleanupChildData)(void* child_data);
56
57AI_API bool AiOpSetTarget(AtUniverse* universe, AtNode* node);
58AI_API AtNode* AiOpGetTarget(const AtUniverse* universe);
59
60AI_API AtArray* AiOpGetInputs(AtNode* op);
61AI_API bool AiOpLink(AtNode* from, AtNode* to, int index = -1);
62AI_API bool AiOpUnlinkInputByIndex(AtNode* to, unsigned int index);
63AI_API bool AiOpUnlink(AtNode* from, AtNode* to);
64
65AI_API void AiOpSetChildData(AtNode* op, void* child_data = NULL, AtOpCleanupChildData cleanup = NULL);
66
67AI_API bool AiOpMatchNodeSelection(AtNode* node, AtString selection, bool relative = true, AtNode* target = NULL);
68
69AI_API AtNode* AiOpCookContextGetCookScope(AtCookContext* cook_context);
70
87typedef bool (*AtOpInit)(AtNode* op, void** user_data);
88
101typedef bool (*AtOpCleanup)(AtNode* op, void* user_data);
102
133typedef bool (*AtOpCook)(AtNode* node, AtNode* op, void* child_data, void* user_data, const AtArray* matching_params, AtCookContext* cook_context);
134
145typedef bool (*AtOpPostCook)(AtNode* op, void* user_data);
146
157{
158 AtOpInit Init;
159 AtOpCleanup Cleanup;
160 AtOpCook Cook;
161 AtOpPostCook PostCook;
162};
163
170typedef int (*AtOpFuncPtr)(AtOperatorNodeMethods* methods);
171
173#define AI_OPERATOR_COMMON_NODE_METHODS \
174node_parameters; \
175static AtCommonMethods ai_common_mtds = { \
176 NULL, \
177 NULL, \
178 Parameters, \
179 NULL, \
180 NULL, \
181 NULL \
182};
183
184#define AI_OPERATOR_NODE_EXPORT_METHODS(tag) \
185AI_OPERATOR_COMMON_NODE_METHODS \
186operator_init; \
187operator_cleanup; \
188operator_cook; \
189operator_post_cook; \
190static AtOperatorNodeMethods ai_op_mtds = { \
191 OperatorInit, \
192 OperatorCleanup, \
193 OperatorCook, \
194 OperatorPostCook \
195}; \
196static AtNodeMethods ai_node_mtds = { \
197 &ai_common_mtds, \
198 &ai_op_mtds \
199}; \
200const AtNodeMethods* tag = &ai_node_mtds;
201
202#define AI_OPERATOR_NODE_INTERNAL_METHODS(tag) \
203AI_INSTANCE_COMMON_METHODS \
204static AtNodeMethods ai_node_internal_mtds = { \
205 &ai_common_mtds, \
206 NULL \
207}; \
208const AtNodeMethods* tag = &ai_node_internal_mtds;
209
210#define operator_init \
211static bool OperatorInit(AtNode* op, void** user_data)
212
213#define operator_cleanup \
214static bool OperatorCleanup(AtNode* op, void* user_data)
215
216#define operator_cook \
217static bool OperatorCook(AtNode* node, AtNode* op, void* child_data, void* user_data, const AtArray* matching_params, AtCookContext* cook_context)
218
219#define operator_post_cook \
220static bool OperatorPostCook(AtNode* op, void* user_data)
221
222/*\}*/
DLL export prefix for API functions (necessary for multi-platform development)
Matrix math type and methods.
AtNode struct and methods.
Version number information and checking of backwards-compatibility.
Arnold String allows for fast string comparisons.
Definition: ai_string.h:46
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
bool(* AtOpInit)(AtNode *op, void **user_data)
Operator init method.
Definition: ai_operator.h:87
int(* AtOpFuncPtr)(AtOperatorNodeMethods *methods)
Operator function pointer entry-point symbol.
Definition: ai_operator.h:170
AI_API AtArray * AiOpGetInputs(AtNode *op)
Get operator nodes connected to the inputs on a given operator node.
Definition: ai_operator.cpp:89
bool(* AtOpCleanup)(AtNode *op, void *user_data)
Operator cleanup method.
Definition: ai_operator.h:101
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 void AiOpSetChildData(AtNode *op, void *child_data=NULL, AtOpCleanupChildData cleanup=NULL)
Set child data on an operator.
Definition: ai_operator.cpp:24
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
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
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:145
AI_API bool AiOpSetTarget(AtUniverse *universe, AtNode *node)
Set the target operator in a given Arnold universe.
Definition: ai_operator.cpp:35
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:133
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 bool AiOpUnlink(AtNode *from, AtNode *to)
Unlink connected operators.
Definition: ai_operator.cpp:211
This represents a node in Arnold.
Cleanup method for child data which is passed to other operators.
Definition: ai_operator.h:157
This represents a universe in Arnold.

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