MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
GraphicsOperator.cpp
Go to the documentation of this file.
2
5
7
8[[nodiscard]] std::vector<DrawRun> GraphicsOperator::topology_runs() const
9{
11 return { DrawRun {
12 .topology = topo,
13 .vertex_offset = 0,
14 .vertex_count = static_cast<uint32_t>(get_vertex_count()) } };
15}
16
18 std::string_view param,
19 const std::shared_ptr<NodeNetwork>& source)
20{
21 size_t point_count = get_point_count();
22
23 if (source->get_node_count() != point_count) {
24 return;
25 }
26
27 if (param == "color") {
28 for (size_t i = 0; i < point_count; ++i) {
29 auto val = source->get_node_output(i);
30 if (!val)
31 continue;
32
33 auto* point = static_cast<PointVertex*>(get_data_at(i));
34 if (point) {
35 float normalized = glm::clamp(static_cast<float>(*val), 0.0F, 1.0F);
36 point->color = glm::vec3(normalized, 0.5F, 1.0F - normalized);
37 }
38 }
39 } else if (param == "size") {
40 for (size_t i = 0; i < point_count; ++i) {
41 auto val = source->get_node_output(i);
42 if (!val)
43 continue;
44
45 auto* point = static_cast<PointVertex*>(get_data_at(i));
46 if (point) {
47 point->size = glm::clamp(static_cast<float>(*val) * 10.0F, 1.0F, 50.0F);
48 }
49 }
50 }
51}
52}
virtual void * get_data_at(size_t global_index)=0
Get mutable access to point at global index.
void apply_one_to_one(std::string_view param, const std::shared_ptr< NodeNetwork > &source) override
Apply ONE_TO_ONE parameter mapping.
virtual size_t get_point_count() const =0
Get source point count (before topology expansion)
virtual size_t get_vertex_count() const =0
Get number of vertices (may differ from point count for topology/path)
virtual std::optional< Portal::Graphics::PrimitiveTopology > declared_topology() const
Topology this operator's vertex data is authored for, if it holds a node to ask.
virtual std::vector< DrawRun > topology_runs() const
Contiguous vertex spans grouped by primitive topology.
Vertex type for point primitives (POINT_LIST topology)
One contiguous span of vertices sharing a primitive topology.