OverviewFilesCommitsIssuesDocsReleasesPeers

proc-nodes / src / register_types.cpp

270 lines · cpp ref:
#include "register_types.h"

// Core types
#include "core/attribute_storage.h"
#include "core/proc_curves.h"
#include "core/proc_geometry.h"
#include "core/proc_instances.h"
#include "core/proc_mesh.h"
#include "core/proc_pointcloud.h"
#include "core/proc_volume.h"

// Graph
#include "graph/graph_exporter.h"
#include "graph/graph_importer.h"
#include "graph/proc_node.h"
#include "graph/proc_node_graph.h"

// Nodes
#include "nodes/geometry_nodes.h"
#include "nodes/input_nodes.h"
#include "nodes/math_nodes.h"
#include "nodes/mesh_primitive_nodes.h"
#include "nodes/noise_nodes.h"
#include "nodes/rotation_nodes.h"
#include "nodes/attribute_nodes.h"
#include "nodes/selection_nodes.h"
#include "nodes/mesh_ops_nodes.h"
#include "nodes/curve_nodes.h"
#include "nodes/point_nodes.h"
#include "nodes/zone_nodes.h"
#include "nodes/instance_nodes.h"
#include "nodes/utility_nodes.h"
#include "nodes/volume_nodes.h"
#include "nodes/volume_grid_nodes.h"

// Scene
#include "scene/proc_geometry_node.h"

// Editor
#ifdef TOOLS_ENABLED
#include "editor/proc_graph_edit.h"
#include "editor/proc_nodes_editor_plugin.h"
#endif

#include <gdextension_interface.h>
#include <godot_cpp/core/defs.hpp>
#include <godot_cpp/godot.hpp>

#ifdef TOOLS_ENABLED
#include <godot_cpp/classes/editor_plugin_registration.hpp>
#endif

using namespace godot;

void initialize_proc_nodes_module(ModuleInitializationLevel p_level) {
#ifdef TOOLS_ENABLED
	if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {
		GDREGISTER_CLASS(ProcGraphEdit);
		GDREGISTER_CLASS(ProcNodesEditorPlugin);
		EditorPlugins::add_by_type<ProcNodesEditorPlugin>();
		return;
	}
#endif

	if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
		return;
	}

	// Core types
	GDREGISTER_CLASS(AttributeArray);
	GDREGISTER_CLASS(ProcMesh);
	GDREGISTER_CLASS(ProcCurves);
	GDREGISTER_CLASS(ProcPointCloud);
	GDREGISTER_CLASS(ProcInstances);
	GDREGISTER_CLASS(ProcGeometry);
	GDREGISTER_CLASS(ProcVolume);

	// Graph
	GDREGISTER_ABSTRACT_CLASS(ProcNode);
	GDREGISTER_CLASS(ProcNodeGraph);
	GDREGISTER_CLASS(GraphImporter);
	GDREGISTER_CLASS(GraphExporter);

	// Input nodes
	GDREGISTER_CLASS(GroupInputNode);
	GDREGISTER_CLASS(GroupOutputNode);
	GDREGISTER_CLASS(ValueNode);
	GDREGISTER_CLASS(VectorNode);
	GDREGISTER_CLASS(IntegerNode);
	GDREGISTER_CLASS(BooleanNode);
	GDREGISTER_CLASS(ColorNode);
	GDREGISTER_CLASS(StringNode);
	GDREGISTER_CLASS(ObjectInfoNode);

	// Math nodes
	GDREGISTER_CLASS(MathNode);
	GDREGISTER_CLASS(VectorMathNode);
	GDREGISTER_CLASS(CombineXYZNode);
	GDREGISTER_CLASS(SeparateXYZNode);
	GDREGISTER_CLASS(BooleanMathNode);
	GDREGISTER_CLASS(CompareNode);
	GDREGISTER_CLASS(ClampNode);
	GDREGISTER_CLASS(MapRangeNode);
	GDREGISTER_CLASS(MixNode);
	GDREGISTER_CLASS(ColorRampNode);
	GDREGISTER_CLASS(FloatCurveNode);
	GDREGISTER_CLASS(RGBCurvesNode);

	// Mesh primitive nodes
	GDREGISTER_CLASS(MeshCubeNode);
	GDREGISTER_CLASS(MeshGridNode);

	// Geometry nodes
	GDREGISTER_CLASS(TransformGeometryNode);
	GDREGISTER_CLASS(SetPositionNode);
	GDREGISTER_CLASS(JoinGeometryNode);
	GDREGISTER_CLASS(ConvexHullNode);
	GDREGISTER_CLASS(GeometryToInstanceNode);
	GDREGISTER_CLASS(ViewerNode);

	// Noise/texture nodes
	GDREGISTER_CLASS(NoiseTextureNode);
	GDREGISTER_CLASS(PerlinNoiseNode);
	GDREGISTER_CLASS(DisplaceNode);
	GDREGISTER_CLASS(VoronoiTextureNode);
	GDREGISTER_CLASS(WaveTextureNode);
	GDREGISTER_CLASS(WhiteNoiseNode);
	GDREGISTER_CLASS(GradientTextureNode);
	GDREGISTER_CLASS(GradientNoiseNode);
	GDREGISTER_CLASS(FractalTerrainNode);
	GDREGISTER_CLASS(HeightfieldNode);
	GDREGISTER_CLASS(ErosionNoiseNode);
	GDREGISTER_CLASS(AltitudeColorNode);
	GDREGISTER_CLASS(SlopeGradientNode);

	// Rotation and matrix family -- needs SocketType::Rotation / ::Matrix.
	GDREGISTER_CLASS(AxisAngleToRotationNode);
	GDREGISTER_CLASS(EulerToRotationNode);
	GDREGISTER_CLASS(QuaternionToRotationNode);
	GDREGISTER_CLASS(RotationToAxisAngleNode);
	GDREGISTER_CLASS(RotationToEulerNode);
	GDREGISTER_CLASS(RotationToQuaternionNode);
	GDREGISTER_CLASS(InvertRotationNode);
	GDREGISTER_CLASS(RotateRotationNode);
	GDREGISTER_CLASS(RotateVectorNode);
	GDREGISTER_CLASS(InputRotationNode);
	GDREGISTER_CLASS(RotateEulerNode);
	GDREGISTER_CLASS(VectorRotateNode);
	GDREGISTER_CLASS(CombineMatrixNode);
	GDREGISTER_CLASS(SeparateMatrixNode);
	GDREGISTER_CLASS(InvertMatrixNode);
	GDREGISTER_CLASS(MatrixDeterminantNode);
	GDREGISTER_CLASS(MatrixMultiplyNode);
	GDREGISTER_CLASS(TransposeMatrixNode);

	// Attribute nodes
	GDREGISTER_CLASS(PositionNode);
	GDREGISTER_CLASS(NormalNode);
	GDREGISTER_CLASS(IndexNode);
	GDREGISTER_CLASS(UVNode);
	GDREGISTER_CLASS(StoreNamedAttributeNode);
	GDREGISTER_CLASS(NamedAttributeNode);
	GDREGISTER_CLASS(CaptureAttributeNode);
	GDREGISTER_CLASS(RemoveNamedAttributeNode);
	GDREGISTER_CLASS(DomainSizeNode);

	// Selection/utility nodes
	GDREGISTER_CLASS(DeleteGeometryNode);
	GDREGISTER_CLASS(BoundingBoxNode);
	GDREGISTER_CLASS(SeparateComponentsNode);
	GDREGISTER_CLASS(SeparateGeometryNode);
	GDREGISTER_CLASS(SwitchNode);
	GDREGISTER_CLASS(RandomValueNode);

	// Mesh primitive nodes (new)
	GDREGISTER_CLASS(MeshCircleNode);
	GDREGISTER_CLASS(MeshCylinderNode);
	GDREGISTER_CLASS(MeshUVSphereNode);
	GDREGISTER_CLASS(MeshIcoSphereNode);
	GDREGISTER_CLASS(MeshLineNode);

	// Mesh operation nodes
	GDREGISTER_CLASS(FlipFacesNode);
	GDREGISTER_CLASS(SetShadeSmoothNode);
	GDREGISTER_CLASS(SubdivideMeshNode);
	GDREGISTER_CLASS(ScaleElementsNode);
	GDREGISTER_CLASS(ExtrudeMeshNode);
	GDREGISTER_CLASS(MergeByDistanceNode);
	GDREGISTER_CLASS(DualMeshNode);
	GDREGISTER_CLASS(DuplicateElementsNode);
	GDREGISTER_CLASS(MeshBooleanNode);
	GDREGISTER_CLASS(SplitEdgesNode);
	GDREGISTER_CLASS(TriangulateNode);
	GDREGISTER_CLASS(EdgePathsToCurvesNode);

	// Curve primitive nodes
	GDREGISTER_CLASS(CurveCircleNode);
	GDREGISTER_CLASS(CurveLineNode);
	GDREGISTER_CLASS(BezierSegmentNode);

	// Curve operation nodes
	GDREGISTER_CLASS(CurveToMeshNode);
	GDREGISTER_CLASS(CurveToPointsNode);
	GDREGISTER_CLASS(ResampleCurveNode);
	GDREGISTER_CLASS(SetCurveRadiusNode);
	GDREGISTER_CLASS(TrimCurveNode);

	// Point nodes
	GDREGISTER_CLASS(PointsNode);
	GDREGISTER_CLASS(PointsToVerticesNode);
	GDREGISTER_CLASS(DistributePointsOnFacesNode);

	// Zone nodes
	GDREGISTER_CLASS(RepeatZoneInputNode);
	GDREGISTER_CLASS(RepeatZoneOutputNode);
	GDREGISTER_CLASS(ForeachZoneInputNode);
	GDREGISTER_CLASS(ForeachZoneOutputNode);
	GDREGISTER_CLASS(SimulationZoneInputNode);
	GDREGISTER_CLASS(SimulationZoneOutputNode);

	// Instance nodes
	GDREGISTER_CLASS(InstanceOnPointsNode);
	GDREGISTER_CLASS(RotateInstancesNode);
	GDREGISTER_CLASS(ScaleInstancesNode);
	GDREGISTER_CLASS(TranslateInstancesNode);
	GDREGISTER_CLASS(RealizeInstancesNode);

	// Volume nodes
	GDREGISTER_CLASS(SphereSdfNode);
	GDREGISTER_CLASS(VolumeBooleanNode);
	GDREGISTER_CLASS(VolumeToMeshNode);
	// The voxel-grid family: Blender's mesh -> SDF grid -> fillet -> mesh chain,
	// which mountain_voronoi1.blend's MTN_Solidify is built from.
	GDREGISTER_CLASS(MeshToSDFGridNode);
	GDREGISTER_CLASS(SDFGridFilletNode);
	GDREGISTER_CLASS(GridToMeshNode);

	// Utility nodes
	GDREGISTER_CLASS(AccumulateFieldNode);
	GDREGISTER_CLASS(SampleIndexNode);

	// Scene
	GDREGISTER_CLASS(ProcGeometryNode);
}

void uninitialize_proc_nodes_module(ModuleInitializationLevel p_level) {
#ifdef TOOLS_ENABLED
	if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {
		return;
	}
#endif

	if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
		return;
	}
}

extern "C" {
GDExtensionBool GDE_EXPORT proc_nodes_init(
		GDExtensionInterfaceGetProcAddress p_get_proc_address,
		GDExtensionClassLibraryPtr p_library,
		GDExtensionInitialization *r_initialization) {
	GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization);
	init_obj.register_initializer(initialize_proc_nodes_module);
	init_obj.register_terminator(uninitialize_proc_nodes_module);
	init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE);
	return init_obj.init();
}
}