Skip to content

Commit

Permalink
If spline doesn't have a GlobalTransform, treat it as if all the poin…
Browse files Browse the repository at this point in the history
…ts are already in world space.
  • Loading branch information
TheGrimsey committed Jan 8, 2025
1 parent c8c2233 commit 0447488
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/modifiers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ pub(super) fn update_terrain_spline_cache(
&mut TerrainSplineCached,
&TerrainSplineShape,
&TerrainSplineProperties,
&GlobalTransform,
Option<&GlobalTransform>,
),
Or<(
Changed<TerrainSplineProperties>,
Expand Down Expand Up @@ -197,12 +197,17 @@ pub(super) fn update_terrain_spline_cache(
subdivisions = (subdivisions as f32 * 1.2) as usize;
}

spline_cached.points.extend(
spline
.curve
.iter_positions(subdivisions)
.map(|point| global_transform.transform_point(point)),
);
if let Some(global_transform) = global_transform {
spline_cached.points.extend(
spline
.curve
.iter_positions(subdivisions)
.map(|point| global_transform.transform_point(point)),
);
} else {
// Without a global transform, assume the curve is in world space already.
spline_cached.points.extend(spline.curve.iter_positions(subdivisions));
}

// Keep last point in case it is removed by dedup.
// First point can't be deleted by dedup so we don't need to save it.
Expand Down

0 comments on commit 0447488

Please sign in to comment.