Skip to content

C++ Updates#13

Open
GoodPie wants to merge 11 commits intomasterfrom
dep-version-bumps
Open

C++ Updates#13
GoodPie wants to merge 11 commits intomasterfrom
dep-version-bumps

Conversation

@GoodPie
Copy link
Owner

@GoodPie GoodPie commented Feb 1, 2026

Description

  • Update to use C++20
    • Was getting a bit messy with hardcoding PI for cross platform and me being lazy and not declaring it in a constants file
  • Updated PyBind
    • Was a lot less scarier than I thought.
    • No code changes and no more warnings
  • Big C++ refactor for C++20
    • Went in with the intention of removing hard-coded PI but got carried away with all the changes in the docs
    • Better to do now vs if it gets larger I guess

Generated Description

This pull request introduces several important updates to the codebase, focusing primarily on modernizing C++ standards, improving type safety and maintainability, updating dependencies, and making minor version bumps across the project. The most significant changes are grouped below:

C++ Modernization and Type Safety

  • Raised the required CMake version to 3.15 and the C++ standard to C++20 in all relevant CMakeLists.txt files, enabling modern language features and better tooling support. [1] [2] [3]
  • Introduced C++20 concepts with a new Mesher concept in TreeMesher.hpp, improving compile-time interface checks for meshers.
  • Replaced the polymorphic GrowthInfo base class with a std::variant-based GrowthInfo type, and updated all usages to use std::get/std::get_if, removing dynamic casts and heap allocations for better type safety and performance. [1] [2] [3] [4] [5] [6]

Dependency and Build System Updates

  • Updated the pybind11 submodule to a newer commit, ensuring compatibility with the latest Python bindings and C++ standards.
  • Removed the -DCMAKE_POLICY_VERSION_MINIMUM=3.5 flag from the build script, as the minimum CMake version is now 3.15.

Code Quality and Consistency

  • Replaced usage of mathematical constants like M_PI with C++20's std::numbers::pi_v<float>, and updated related calculations throughout ManifoldMesher.cpp and BranchFunction.cpp for improved portability and clarity. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]
  • Made string constants in ManifoldMesher::AttributeNames const, improving immutability and clarity.

Version Bumps

  • Bumped the project version to 5.3.1 in all relevant files (VERSION, blender_manifest.toml, pyproject.toml) to reflect these changes. [1] [2] [3]

These changes collectively modernize the codebase, improve safety and maintainability, and update dependencies for a smoother development experience.

Was less scarier than I thought
- Use standard math library that's now cross platform to remove PI hard-codes and standardise other features
- Use std::ranges
- Added "concepts"
- Added templates

Honestly, this was me experimenting with C++ after many years so I went ham
@GoodPie GoodPie self-assigned this Feb 1, 2026
Copilot AI review requested due to automatic review settings February 1, 2026 05:30
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the C++ codebase to use the C++20 standard and modernizes the build system, replacing hardcoded PI constants with std::numbers::pi_v<float> and refactoring the growth information system from pointer-based polymorphism to std::variant.

Changes:

  • Updated CMake minimum version to 3.15 and C++ standard to C++20 across all build configurations
  • Replaced hardcoded PI constants with C++20's std::numbers::pi_v<float>
  • Refactored GrowthInfo from a pointer-based inheritance hierarchy to a std::variant<std::monostate, BranchGrowthInfo, BioNodeInfo>, eliminating dynamic allocations

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pyproject.toml Version bump to 5.3.1
m_tree/tests/main.cpp Enhanced test coverage for BranchFunction and GrowthFunction
m_tree/tests/CMakeLists.txt Updated to CMake 3.15-3.31 and C++20
m_tree/source/utilities/GeometryUtilities.hpp Removed hardcoded PI definition, added <numbers> include
m_tree/source/utilities/GeometryUtilities.cpp Replaced M_PI with std::numbers::pi_v<float>, added std prefix to abs()
m_tree/source/tree_functions/base_types/TreeFunction.hpp Added C++20 concept TreeFunctionType
m_tree/source/tree_functions/base_types/Property.hpp Added C++20 concept PropertyFunction and renamed parameters for clarity
m_tree/source/tree_functions/GrowthFunction.hpp Removed BioNodeInfo class definition (moved to GrowthInfo.hpp)
m_tree/source/tree_functions/GrowthFunction.cpp Removed #pragma once, refactored to use std::variant with std::get
m_tree/source/tree_functions/CrownShape.hpp Replaced hardcoded PI constants with std::numbers::pi_v<float>
m_tree/source/tree_functions/BranchFunction.hpp Removed BranchGrowthInfo class definition (moved to GrowthInfo.hpp)
m_tree/source/tree_functions/BranchFunction.cpp Refactored to use std::variant, added designated initializers, replaced PI constants
m_tree/source/tree/Node.hpp Changed growthInfo from std::unique_ptr<GrowthInfo> to GrowthInfo (variant)
m_tree/source/tree/GrowthInfo.hpp Restructured to use std::variant with BranchGrowthInfo and BioNodeInfo structs
m_tree/source/meshers/manifold_mesher/ManifoldMesher.hpp Made attribute name strings const, added <string> include
m_tree/source/meshers/manifold_mesher/ManifoldMesher.cpp Replaced PI constants, added designated initializers
m_tree/source/meshers/base_types/TreeMesher.hpp Added C++20 concept Mesher
m_tree/source/CMakeLists.txt Updated to CMake 3.15-3.31 and C++20
m_tree/python_bindings/CMakeLists.txt Updated to CMake 3.15-3.31 and C++20
m_tree/pyproject.toml Version bump to 5.3.1
m_tree/install.py Removed deprecated CMake policy argument
m_tree/dependencies/pybind11 Updated pybind11 submodule to newer commit
m_tree/CMakeLists.txt Updated to CMake 3.15-3.31 and C++20
blender_manifest.toml Version bump to 5.3.1
VERSION Version bump to 5_3_1
Comments suppressed due to low confidence (1)

m_tree/source/tree_functions/BranchFunction.cpp:1

  • Missing space before multiplication operator. The expression pi_v<float>)*child_radial_n should be pi_v<float>) * child_radial_n for better readability.
#include <iostream>

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@GoodPie GoodPie requested a review from Copilot February 1, 2026 05:31
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 25 out of 25 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

m_tree/source/tree_functions/BranchFunction.cpp:1

  • Missing space around the * operator. Should be std::numbers::pi_v<float>) * child_radial_n for consistency with code style.
#include <iostream>

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@GoodPie GoodPie added dependencies Pull requests that update a dependency file refactor No functional changes, just tidy ups (hopefully) labels Feb 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file refactor No functional changes, just tidy ups (hopefully)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant