Remap filament for pre-colored models (#10303)

* Add a new feature to allow users to remap filament for a pre-painted model.

* Fix the color issues to support the theme

* clean up code

* Fix broken freetype-2.12.1.tar.gz link
This commit is contained in:
SoftFever
2025-08-03 13:28:03 +08:00
committed by GitHub
parent e5ea789b89
commit f27a40d29b
4 changed files with 276 additions and 5 deletions

View File

@@ -37,6 +37,9 @@ enum class EnforcerBlockerType : int8_t {
ExtruderMax = Extruder16
};
// Type alias for the state mapping array to improve code readability
using EnforcerBlockerStateMap = std::array<EnforcerBlockerType, (size_t)EnforcerBlockerType::ExtruderMax + 1>;
// Following class holds information about selected triangles. It also has power
// to recursively subdivide the triangles and make the selection finer.
class TriangleSelector
@@ -344,6 +347,10 @@ public:
// Remove all unnecessary data.
void garbage_collect();
// Orca: remap the state of triangles according to the state_map
void remap_triangle_state(const EnforcerBlockerStateMap& state_map);
// Store the division trees in compact form (a long stream of bits for each triangle of the original mesh).
// First vector contains pairs of (triangle index, first bit in the second vector).
TriangleSplittingData serialize() const;
@@ -416,10 +423,17 @@ protected:
// or index of a vertex shared by the two split edges (for number_of_splits == 2).
// For number_of_splits == 3, special_side_idx is always zero.
char special_side_idx { 0 };
EnforcerBlockerType state;
bool m_selected_by_seed_fill : 1;
// Is this triangle valid or marked to be removed?
bool m_valid : 1;
// Orca:
// IMPORTANT: `state` is intentionally placed after all other small members
// to prevent compilers from packing it in a way that would create
// data races during parallel processing. A write to `state` could
// otherwise become a non-atomic read-modify-write on a memory word
// that also contains other (bit-field) members, causing race conditions.
EnforcerBlockerType state;
};
struct Vertex {