mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-27 10:51:22 +00:00
Fixes from Full spectrum port
https://github.com/OrcaSlicer/OrcaSlicer/pull/14383
This commit is contained in:
@@ -3795,7 +3795,7 @@ unsigned int PresetBundle::sync_ams_list(std::vector<std::pair<DynamicPrintConfi
|
||||
return -1;
|
||||
};
|
||||
for (size_t i = 0; i < need_append_colors.size(); i++){
|
||||
if (exist_filament_presets.size() >= size_t(EnforcerBlockerType::ExtruderMax)){
|
||||
if (exist_filament_presets.size() >= MAXIMUM_AMS_SYNC_FILAMENT_NUMBER){
|
||||
break;
|
||||
}
|
||||
auto idx = get_idx_in_array(exist_filament_presets, exist_colors, need_append_colors[i].filament_preset, need_append_colors[i].filament_color);
|
||||
|
||||
@@ -1931,7 +1931,8 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_
|
||||
for (const ModelVolume *volume : volumes) {
|
||||
const std::vector<bool> &volume_used_facet_states = volume->mmu_segmentation_facets.get_data().used_states;
|
||||
|
||||
assert(volume_used_facet_states.size() == used_facet_states.size());
|
||||
// Sizes may legitimately differ: paint data stored before the state range was
|
||||
// extended carries a shorter used_states vector. Merge over the common prefix.
|
||||
for (size_t state_idx = 0; state_idx < std::min(volume_used_facet_states.size(), used_facet_states.size()); ++state_idx)
|
||||
used_facet_states[state_idx] |= volume_used_facet_states[state_idx];
|
||||
}
|
||||
|
||||
@@ -1736,13 +1736,22 @@ TriangleSelector::TriangleSplittingData TriangleSelector::serialize() const {
|
||||
data.used_states[n] = true;
|
||||
|
||||
if (n >= 3) {
|
||||
assert(n <= 16);
|
||||
if (n <= 16) {
|
||||
// Store "11" plus 4 bits of (n-3).
|
||||
data.bitstream.insert(data.bitstream.end(), { true, true });
|
||||
n -= 3;
|
||||
assert(n <= int(EnforcerBlockerType::ExtruderMax));
|
||||
// Store "11" plus 4 bits of (n-3), which covers states 3..17. State 18 and
|
||||
// above set that nibble to 0b1111 and store (n-18) in a second nibble. This is
|
||||
// the encoding the CONST_FILAMENTS table in Model.cpp already writes for
|
||||
// colored mesh imports.
|
||||
data.bitstream.insert(data.bitstream.end(), { true, true });
|
||||
auto &bitstream = data.bitstream;
|
||||
auto push_nibble = [&bitstream](int value) {
|
||||
for (size_t bit_idx = 0; bit_idx < 4; ++bit_idx)
|
||||
data.bitstream.push_back(n & (uint64_t(0b0001) << bit_idx));
|
||||
bitstream.push_back(value & (uint64_t(0b0001) << bit_idx));
|
||||
};
|
||||
if (n <= 17) {
|
||||
push_nibble(n - 3);
|
||||
} else {
|
||||
push_nibble(0b1111);
|
||||
push_nibble(n - 18);
|
||||
}
|
||||
} else {
|
||||
// Simple case, compatible with PrusaSlicer 2.3.1 and older for storing paint on supports and seams.
|
||||
@@ -1810,6 +1819,12 @@ void TriangleSelector::deserialize(const TriangleSplittingData &data,
|
||||
n |= data.bitstream[ibit ++] << i;
|
||||
return n;
|
||||
};
|
||||
// Decode a leaf state stored behind the "11" prefix: one nibble of (state-3) for states
|
||||
// 3..17, or 0b1111 followed by a nibble of (state-18) above that.
|
||||
auto decode_leaf_state = [&next_nibble]() {
|
||||
const int nibble = next_nibble();
|
||||
return EnforcerBlockerType(nibble == 0b1111 ? next_nibble() + 18 : nibble + 3);
|
||||
};
|
||||
|
||||
parents.clear();
|
||||
while (true) {
|
||||
@@ -1818,8 +1833,8 @@ void TriangleSelector::deserialize(const TriangleSplittingData &data,
|
||||
int num_of_split_sides = code & 0b11;
|
||||
int num_of_children = num_of_split_sides == 0 ? 0 : num_of_split_sides + 1;
|
||||
bool is_split = num_of_children != 0;
|
||||
// Only valid if not is_split. Value of the second nibble was subtracted by 3, so it is added back.
|
||||
auto state = is_split ? EnforcerBlockerType::NONE : EnforcerBlockerType((code & 0b1100) == 0b1100 ? next_nibble() + 3 : code >> 2);
|
||||
// Only valid if not is_split.
|
||||
auto state = is_split ? EnforcerBlockerType::NONE : ((code & 0b1100) == 0b1100 ? decode_leaf_state() : EnforcerBlockerType(code >> 2));
|
||||
|
||||
// BBS
|
||||
if (state == to_delete_filament)
|
||||
@@ -1916,7 +1931,14 @@ void TriangleSelector::TriangleSplittingData::update_used_states(const size_t bi
|
||||
if (const bool is_split = (code & 0b11) != 0; is_split)
|
||||
continue;
|
||||
|
||||
const uint8_t facet_state = (code & 0b1100) == 0b1100 ? read_next_nibble() + 3 : code >> 2;
|
||||
uint8_t facet_state;
|
||||
if ((code & 0b1100) == 0b1100) {
|
||||
// Leaf behind the "11" prefix: one nibble of (state-3), or 0b1111 + (state-18).
|
||||
const uint8_t nibble = read_next_nibble();
|
||||
facet_state = nibble == 0b1111 ? uint8_t(read_next_nibble() + 18) : uint8_t(nibble + 3);
|
||||
} else {
|
||||
facet_state = code >> 2;
|
||||
}
|
||||
assert(facet_state < this->used_states.size());
|
||||
if (facet_state >= this->used_states.size())
|
||||
continue;
|
||||
@@ -1946,9 +1968,13 @@ bool TriangleSelector::has_facets(const TriangleSplittingData &data, const Enfor
|
||||
auto num_children_or_state = [&next_nibble]() -> int {
|
||||
int code = next_nibble();
|
||||
int num_of_split_sides = code & 0b11;
|
||||
return num_of_split_sides == 0 ?
|
||||
((code & 0b1100) == 0b1100 ? next_nibble() + 3 : code >> 2) :
|
||||
- num_of_split_sides - 1;
|
||||
if (num_of_split_sides != 0)
|
||||
return - num_of_split_sides - 1;
|
||||
if ((code & 0b1100) != 0b1100)
|
||||
return code >> 2;
|
||||
// Leaf behind the "11" prefix: one nibble of (state-3), or 0b1111 + (state-18).
|
||||
const int nibble = next_nibble();
|
||||
return nibble == 0b1111 ? next_nibble() + 18 : nibble + 3;
|
||||
};
|
||||
|
||||
int state = num_children_or_state();
|
||||
|
||||
@@ -17,7 +17,9 @@ enum class EnforcerBlockerType : int8_t {
|
||||
BLOCKER = 2,
|
||||
// For the fuzzy skin, we use just two values (NONE and FUZZY_SKIN).
|
||||
FUZZY_SKIN = ENFORCER,
|
||||
// Maximum is 15. The value is serialized in TriangleSelector into 6 bits using a 2 bit prefix code.
|
||||
// States 3..17 are serialized into 6 bits using a 2 bit prefix code; states 18 and above use
|
||||
// one additional nibble (see TriangleSelector::serialize). ExtruderMax matches the last entry
|
||||
// of CONST_FILAMENTS in Model.cpp, which encodes the same range for colored mesh imports.
|
||||
Extruder1 = ENFORCER,
|
||||
Extruder2 = BLOCKER,
|
||||
Extruder3,
|
||||
@@ -34,7 +36,23 @@ enum class EnforcerBlockerType : int8_t {
|
||||
Extruder14,
|
||||
Extruder15,
|
||||
Extruder16,
|
||||
ExtruderMax = Extruder16
|
||||
Extruder17,
|
||||
Extruder18,
|
||||
Extruder19,
|
||||
Extruder20,
|
||||
Extruder21,
|
||||
Extruder22,
|
||||
Extruder23,
|
||||
Extruder24,
|
||||
Extruder25,
|
||||
Extruder26,
|
||||
Extruder27,
|
||||
Extruder28,
|
||||
Extruder29,
|
||||
Extruder30,
|
||||
Extruder31,
|
||||
Extruder32,
|
||||
ExtruderMax = Extruder32
|
||||
};
|
||||
|
||||
// Type alias for the state mapping array to improve code readability
|
||||
|
||||
@@ -64,6 +64,12 @@ static constexpr double LARGE_BED_THRESHOLD = 2147;
|
||||
// Orca: maximum number of extruders is 64. For SEMM printers, it defines maximum filament number.
|
||||
static constexpr size_t MAXIMUM_EXTRUDER_NUMBER = 64;
|
||||
|
||||
// Orca: how many filament slots syncing an AMS setup may create. This used to follow
|
||||
// EnforcerBlockerType::ExtruderMax, which capped it at the number of paintable filaments; that
|
||||
// limit has since been raised to 32, so the value is pinned here to keep AMS sync behaving as
|
||||
// before for projects that use no mixed-colour filaments.
|
||||
static constexpr size_t MAXIMUM_AMS_SYNC_FILAMENT_NUMBER = 16;
|
||||
|
||||
// Orca: maximum line width is 5 times the nozzle diameter
|
||||
static constexpr float MAX_LINE_WIDTH_MULTIPLIER = 5;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user