OverviewFilesCommitsIssuesDocsReleasesPeers

proc-nodes / src / nodes / geometry_nodes.h

126 lines · c ref:
#ifndef PROC_NODES_GEOMETRY_NODES_H
#define PROC_NODES_GEOMETRY_NODES_H

#include "../graph/proc_node.h"

namespace godot {

// Transform Geometry — translate, rotate, scale
class TransformGeometryNode : public ProcNode {
	GDCLASS(TransformGeometryNode, ProcNode);

protected:
	static void _bind_methods();

public:
	StringName get_node_type() const override { return "TransformGeometry"; }
	String get_node_title() const override { return "Transform Geometry"; }
	String get_node_category() const override { return "Geometry"; }
	bool supports_gpu() const override { return true; }

	void execute(ProcEvalContext &p_ctx, int p_node_idx) override;
	String compile_glsl(const GlslEmitContext &p_ctx, int p_node_idx) const override;

	TransformGeometryNode();
};

// Set Position — offset all positions by a vector
class SetPositionNode : public ProcNode {
	GDCLASS(SetPositionNode, ProcNode);

protected:
	static void _bind_methods();

public:
	StringName get_node_type() const override { return "SetPosition"; }
	String get_node_title() const override { return "Set Position"; }
	String get_node_category() const override { return "Geometry"; }
	bool supports_gpu() const override { return true; }

	// Offset ONLY -- socket 3, three floats in param0..param2.
	//
	// Selection (1) and Position (2) are deliberately absent: the batch shader
	// has no way to express a per-element selection or an implicit position
	// field, so GraphExecutor falls back to the CPU when either is connected
	// rather than dispatching a shader that silently ignores them.
	PackedInt32Array get_push_constant_sockets() const override {
		PackedInt32Array m;
		m.push_back(3);
		return m;
	}

	void execute(ProcEvalContext &p_ctx, int p_node_idx) override;
	String compile_glsl(const GlslEmitContext &p_ctx, int p_node_idx) const override;

	SetPositionNode();
};

// Join Geometry — combine multiple geometries
class JoinGeometryNode : public ProcNode {
	GDCLASS(JoinGeometryNode, ProcNode);

protected:
	static void _bind_methods();

public:
	StringName get_node_type() const override { return "JoinGeometry"; }
	String get_node_title() const override { return "Join Geometry"; }
	String get_node_category() const override { return "Geometry"; }

	void execute(ProcEvalContext &p_ctx, int p_node_idx) override;

	JoinGeometryNode();
};

// Convex Hull — compute convex hull of input mesh
class ConvexHullNode : public ProcNode {
	GDCLASS(ConvexHullNode, ProcNode);

protected:
	static void _bind_methods();

public:
	StringName get_node_type() const override { return "ConvexHull"; }
	String get_node_title() const override { return "Convex Hull"; }
	String get_node_category() const override { return "Geometry"; }

	void execute(ProcEvalContext &p_ctx, int p_node_idx) override;
	ConvexHullNode();
};

// Geometry To Instance — convert geometry to a single instance
class GeometryToInstanceNode : public ProcNode {
	GDCLASS(GeometryToInstanceNode, ProcNode);

protected:
	static void _bind_methods();

public:
	StringName get_node_type() const override { return "GeometryToInstance"; }
	String get_node_title() const override { return "Geometry to Instance"; }
	String get_node_category() const override { return "Geometry"; }

	void execute(ProcEvalContext &p_ctx, int p_node_idx) override;
	GeometryToInstanceNode();
};

// Viewer — debug output (passes geometry through, marks for display)
class ViewerNode : public ProcNode {
	GDCLASS(ViewerNode, ProcNode);

protected:
	static void _bind_methods();

public:
	StringName get_node_type() const override { return "Viewer"; }
	String get_node_title() const override { return "Viewer"; }
	String get_node_category() const override { return "Geometry"; }

	void execute(ProcEvalContext &p_ctx, int p_node_idx) override;
	ViewerNode();
};

} // namespace godot

#endif // PROC_NODES_GEOMETRY_NODES_H