Skip to content
Merged
3 changes: 2 additions & 1 deletion editor/src/messages/input_mapper/utility_types/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ impl FrameTimeInfo {
}

pub fn advance_timestamp(&mut self, next_timestamp: Duration) {
debug_assert!(next_timestamp >= self.timestamp);
// Guard against non-monotonic timestamps from the browser (Keavon observed this once in Chrome)
let next_timestamp = next_timestamp.max(self.timestamp);

self.prev_timestamp = Some(self.timestamp);
self.timestamp = next_timestamp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4005,6 +4005,14 @@ impl NodeNetworkInterface {
}
}
(_, NodeInput::Node { node_id: upstream_node_id, .. }) => {
// If the old input wasn't exposed but the new one is (`Node` inputs are always exposed),
// the node's port count changed, so its click targets need to be recomputed
if !old_input.is_exposed()
&& let InputConnector::Node { node_id, .. } = input_connector
{
self.unload_node_click_targets(node_id, network_path);
}

// Load structure if the change is to the document network and to the first or second
if network_path.is_empty() {
if matches!(input_connector, InputConnector::Export(0)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,15 @@ impl SelectedEdges {
let original_from_pivot = updated - pivot; // The original vector from the point to the pivot
let mut scale_factor = new_from_pivot / original_from_pivot;

// Constrain should always scale by the same factor in x and y
// Constrain should always scale by the same factor in x and y.
// When one axis of `original_from_pivot` is near zero (e.g. for a line's degenerate bounding box),
// the scale factor for that axis is numerically unstable, so we copy from the more stable axis.
if constrain {
// When the point is on the pivot, we simply copy the other axis.
if original_from_pivot.x.abs() < 1e-5 {
if original_from_pivot.x.abs() < original_from_pivot.y.abs() {
scale_factor.x = scale_factor.y;
} else if original_from_pivot.y.abs() < 1e-5 {
} else {
scale_factor.y = scale_factor.x;
}

debug_assert!((scale_factor.x - scale_factor.y).abs() < 1e-5);
}

if !(self.left || self.right || constrain) {
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/widgets/inputs/ColorInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
background-repeat: var(--color-transparent-checkered-background-repeat);
}

&:not(.disabled).none > button {
&.none > button {
background: var(--color-none);
background-repeat: var(--color-none-repeat);
background-position: var(--color-none-position);
Expand All @@ -132,6 +132,7 @@
left: 0;
right: 0;
background: var(--color-4-dimgray);
opacity: 0.5;
}

&:not(.disabled):hover > button .text-label,
Expand Down
3 changes: 3 additions & 0 deletions node-graph/graph-craft/src/document/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ macro_rules! tagged_value {
// Tries using the default for the tagged value type. If it not implemented, then uses the default used in document_node_types. If it is not used there, then TaggedValue::None is returned.
Some(match concrete_type.id? {
x if x == TypeId::of::<()>() => TaggedValue::None,
// Table-wrapped types need a single-row default with the element's default, not an empty table
x if x == TypeId::of::<Table<Color>>() => TaggedValue::Color(Table::new_from_element(Color::default())),
x if x == TypeId::of::<Table<GradientStops>>() => TaggedValue::GradientTable(Table::new_from_element(GradientStops::default())),
$( x if x == TypeId::of::<$ty>() => TaggedValue::$identifier(Default::default()), )*
_ => return None,
})
Expand Down
4 changes: 3 additions & 1 deletion node-graph/libraries/rendering/src/render_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ impl RenderExt for Stroke {
return String::new();
}

let default_weight = if self.align != StrokeAlign::Center && render_params.aligned_strokes { 1. / 2. } else { 1. };

// Set to None if the value is the SVG default
let weight = (self.weight != 1.).then_some(self.weight);
let weight = (self.weight != default_weight).then_some(self.weight);
let dash_array = (!self.dash_lengths.is_empty()).then_some(self.dash_lengths());
let dash_offset = (self.dash_offset != 0.).then_some(self.dash_offset);
let stroke_cap = (self.cap != StrokeCap::Butt).then_some(self.cap);
Expand Down
6 changes: 3 additions & 3 deletions node-graph/libraries/vector-types/src/vector/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ impl Fill {

pub fn lerp(&self, other: &Self, time: f64) -> Self {
let transparent = Self::solid(Color::TRANSPARENT);
let a = if *self == Self::None { &transparent } else { self };
let b = if *other == Self::None { &transparent } else { other };
let a = if *self == Self::None && *other != Self::None { &transparent } else { self };
let b = if *other == Self::None && *self != Self::None { &transparent } else { other };

match (a, b) {
(Self::Solid(a), Self::Solid(b)) => Self::Solid(a.lerp(b, time as f32)),
Expand All @@ -82,7 +82,7 @@ impl Fill {
Self::Gradient(a.lerp(b, time))
}
(Self::Gradient(a), Self::Gradient(b)) => Self::Gradient(a.lerp(b, time)),
_ => Self::None,
(Self::None, _) | (_, Self::None) => Self::None,
}
}

Expand Down
Loading