Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/collision/collider/parry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ impl Collider {
"Each row in `heights` must have the same amount of points"
);

let heights = nalgebra::DMatrix::from_vec(row_count, column_count, data);
let heights = nalgebra::DMatrix::from_vec(column_count, row_count, data);
Copy link

@Nopey Nopey Jul 20, 2025

Choose a reason for hiding this comment

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

Please do not pass column_count to the nrows argument.

DMatrix::from_vec's first argument is nrows, and second is ncol; the bug is in the calculation of column and row count, and the general confusion of order.
Instead of switching the order of the arguments, the two variables' assignments should be switched.

EDIT: the above assertion "Each row in heights must have the same amount of points" also insists that heights/data is row-major, which doesn't match what's being done with nalgebra below. Adding a transpose would preserve the original intention of ::heightfield, but may be considered a breaking change.

EDIT 2: DMatrix::from_row_iterator is the only row-major DMatrix constructor I see that wouldn't necessitate an additional allocation.

SharedShape::heightfield(heights, scale.into()).into()
}

Expand Down
Loading