Enzo
Loading...
Searching...
No Matches
MeshAttributeReader.h
1#pragma once
2#include "Engine/Attribute/AttributeHandle.h"
3#include "Engine/Core/Types.h"
4#include <array>
5#include <string_view>
6#include <variant>
7#include <vector>
8
9namespace enzo::geo {
10class Mesh;
11}
12
13namespace enzo::script {
14
16using ScriptAttributeHandle = std::variant<
17 std::monostate,
18 attr::AttributeHandleRO<floatT>,
19 attr::AttributeHandleRO<intT>,
20 attr::AttributeHandleRO<Vector3>,
21 attr::AttributeHandleRO<boolT>>;
22
25{
26 String name;
28 ScriptAttributeHandle handle;
29};
30
42{
43 public:
44 explicit MeshAttributeReader(const geo::Mesh& mesh);
45
47 bool hasElement(attr::AttributeOwner owner, intT index) const;
48
51 const ScriptAttribute* getAttribute(attr::AttributeOwner owner, std::string_view name) const;
52
53 private:
54 static constexpr size_t ownerCount = 4;
55
56 std::array<Offset, ownerCount> elementCounts_;
57 std::array<std::vector<ScriptAttribute>, ownerCount> attributes_;
58};
59
60} // namespace enzo::script
Basic attribute, parameter, and node types for Enzo.
AttributeType
Data types available to store attribute values in.
Definition Types.h:37
AttributeOwner
The segment of geometry that owns a particular attribute.
Definition Types.h:27
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
const ScriptAttribute * getAttribute(attr::AttributeOwner owner, std::string_view name) const
Returns the attribute with a name on an owner.
Definition MeshAttributeReader.cpp:49
bool hasElement(attr::AttributeOwner owner, intT index) const
Returns whether an owner has an element at an index.
Definition MeshAttributeReader.cpp:43
An attribute of the mesh that a script reads by name.
Definition MeshAttributeReader.h:25