Enzo
Loading...
Searching...
No Matches
ScriptContext.h
1#pragma once
2#include "Engine/Expression/ExpressionContext.h"
3#include "Engine/Script/MeshAttributeReader.h"
4#include <memory>
5#include <mutex>
6#include <optional>
7#include <vector>
8
9namespace enzo {
10class NodePacket;
11}
12
13namespace enzo::geo {
14class Mesh;
15}
16
17namespace enzo::script {
18
28{
29 public:
31
33 const geo::Mesh& getInputMesh(size_t primitiveIndex) const;
34
36 const MeshAttributeReader& getAttributeReader(size_t primitiveIndex) const;
37
39 void addWarning(const String& warning) const;
40
42 const std::vector<String>& getWarnings() const { return warnings_; }
43
44 private:
45 // One entry per primitive of the input, empty for a primitive that isn't a mesh.
46 std::vector<std::shared_ptr<const geo::Mesh>> inputMeshes_;
47 std::vector<std::optional<MeshAttributeReader>> attributeReaders_;
48
49 mutable std::mutex warningMutex_;
50 mutable std::vector<String> warnings_;
51};
52
53} // namespace enzo::script
uint64_t NodeId
The unique ID assigned to each node in the network.
Definition Types.h:335
Definition NodePacket.h:12
The world a single expression evaluation reads and writes to.
Definition ExpressionContext.h:28
nt::NodeId currentNode() const
The node a relative parameter path resolves against.
Definition ExpressionContext.h:33
Polygonal mesh primitive with point, vertex, and face attributes.
A mesh's attributes by name, with a read handle for each.
Definition MeshAttributeReader.h:42
The world a script reads during one cook of a node.
Definition ScriptContext.h:28
const MeshAttributeReader & getAttributeReader(size_t primitiveIndex) const
Returns the reader for the input mesh at a primitive index.
Definition ScriptContext.cpp:31
void addWarning(const String &warning) const
Adds a warning for the node, skipping one it already holds.
Definition ScriptContext.cpp:36
const geo::Mesh & getInputMesh(size_t primitiveIndex) const
Returns the input mesh at a primitive index.
Definition ScriptContext.cpp:26
const std::vector< String > & getWarnings() const
Returns every warning the script added, in the order they first appeared.
Definition ScriptContext.h:42