MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
GraphicsOperator.hpp
Go to the documentation of this file.
1#pragma once
2
4#include "NetworkOperator.hpp"
5
7
8/**
9 * @class GraphicsOperator
10 * @brief Operator that produces GPU-renderable geometry
11 *
12 * Adds graphics-specific interface (vertex data, position extraction)
13 * on top of base NetworkOperator. Uses glm::vec3 for positions since
14 * that's the graphics domain standard.
15 */
16class MAYAFLUX_API GraphicsOperator : public NetworkOperator {
17public:
18 /**
19 * @brief Get vertex data for GPU upload
20 */
21 [[nodiscard]] virtual std::span<const uint8_t> get_vertex_data() const = 0;
22
23 /**
24 * @brief Get vertex data for specific collection (if multiple)
25 * @param idx Collection index
26 */
27 [[nodiscard]] virtual std::span<const uint8_t> get_vertex_data_for_collection(uint32_t idx = 0) const = 0;
28
29 /**
30 * @brief Get vertex layout describing vertex structure
31 */
32 [[nodiscard]] virtual Kakshya::VertexLayout get_vertex_layout() const = 0;
33
34 /**
35 * @brief Get number of vertices (may differ from point count for topology/path)
36 */
37 [[nodiscard]] virtual size_t get_vertex_count() const = 0;
38
39 /**
40 * @brief Check if geometry changed this frame
41 */
42 [[nodiscard]] virtual bool is_vertex_data_dirty() const = 0;
43
44 /**
45 * @brief Clear dirty flag after GPU upload
46 */
47 virtual void mark_vertex_data_clean() = 0;
48
49 /**
50 * @brief Get source point count (before topology expansion)
51 */
52 [[nodiscard]] virtual size_t get_point_count() const = 0;
53
54 /**
55 * @brief Apply ONE_TO_ONE parameter mapping
56 *
57 * Default implementation handles common graphics properties:
58 * - "color": Per-point color
59 * - "size": Per-point size (for point rendering)
60 */
61 void apply_one_to_one(
62 std::string_view param,
63 const std::shared_ptr<NodeNetwork>& source) override;
64
65 /**
66 * @brief Get human-readable vertex type name (for validation/debugging)
67 */
68 [[nodiscard]] virtual const char* get_vertex_type_name() const = 0;
69
70 /**
71 * @brief Whether this operator contributes a vertex slice to rendering.
72 *
73 * Default true. Set false for transform-only chain operators (e.g. a
74 * FieldOperator deforming upstream vertices) that must not add an
75 * independent render slice.
76 */
77 [[nodiscard]] bool participates_in_rendering() const { return m_participates_in_rendering; }
78 void set_participates_in_rendering(bool value) { m_participates_in_rendering = value; }
79
80 /**
81 * @brief Whether this operator requests upstream vertex state before process().
82 *
83 * Default false. Set true for operators that derive their initial vertex
84 * data from the preceding operator in the chain rather than from an
85 * explicit initialize() call.
86 */
87 [[nodiscard]] bool consumes_upstream() const { return m_consumes_upstream; }
88 void set_consumes_upstream(bool value) { m_consumes_upstream = value; }
89
90 /**
91 * @brief Receive upstream vertex state before process() is called.
92 *
93 * Called by OperatorChain::process() only when consumes_upstream() is true.
94 * Implementations seed their internal vertex buffer from the upstream
95 * operator's current output. Default no-op.
96 *
97 * @param upstream Last GraphicsOperator that ran before this one in the
98 * chain, or the primary operator if this is the first chain
99 * entry. Null if no upstream GraphicsOperator exists.
100 */
101 virtual void seed_from_upstream(const GraphicsOperator* upstream) { }
102
103 /**
104 * @brief Override the dt passed by the caller with a fixed internal value.
105 *
106 * Useful when the owning network passes 0.0F or a sample-count dt that is
107 * meaningless for time-based integration (e.g. PhysicsOperator in a
108 * PointCloudNetwork chain). When true, process() ignores the incoming dt
109 * and substitutes m_internal_dt instead.
110 */
111 void set_force_internal_dt(bool value) { m_force_internal_dt = value; }
112 [[nodiscard]] bool uses_force_internal_dt() const { return m_force_internal_dt; }
113
114protected:
115 /**
116 * @brief Get mutable access to point at global index
117 * @return Pointer to vertex data, or nullptr if index invalid
118 *
119 * Subclasses must implement to provide per-point access
120 */
121 virtual void* get_data_at(size_t global_index) = 0;
122
123 bool m_participates_in_rendering { true };
124 bool m_consumes_upstream {};
125 bool m_force_internal_dt {};
126};
127
128} // namespace MayaFlux::Nodes::Network::Operators
bool participates_in_rendering() const
Whether this operator contributes a vertex slice to rendering.
virtual void * get_data_at(size_t global_index)=0
Get mutable access to point at global index.
virtual size_t get_point_count() const =0
Get source point count (before topology expansion)
virtual std::span< const uint8_t > get_vertex_data_for_collection(uint32_t idx=0) const =0
Get vertex data for specific collection (if multiple)
virtual size_t get_vertex_count() const =0
Get number of vertices (may differ from point count for topology/path)
virtual void seed_from_upstream(const GraphicsOperator *upstream)
Receive upstream vertex state before process() is called.
virtual Kakshya::VertexLayout get_vertex_layout() const =0
Get vertex layout describing vertex structure.
virtual bool is_vertex_data_dirty() const =0
Check if geometry changed this frame.
bool consumes_upstream() const
Whether this operator requests upstream vertex state before process().
void set_force_internal_dt(bool value)
Override the dt passed by the caller with a fixed internal value.
virtual std::span< const uint8_t > get_vertex_data() const =0
Get vertex data for GPU upload.
virtual const char * get_vertex_type_name() const =0
Get human-readable vertex type name (for validation/debugging)
virtual void mark_vertex_data_clean()=0
Clear dirty flag after GPU upload.
Operator that produces GPU-renderable geometry.
Domain-agnostic interpretive lens for network processing.
Complete description of vertex data layout in a buffer.