Skip to content

Commit

Permalink
fix header translating transformations (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
Baezon authored Sep 29, 2023
1 parent d165d23 commit a6c78ac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pof/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2365,12 +2365,12 @@ impl Model {
pub fn apply_subobj_transform(&mut self, id: ObjectId, matrix: &TMat4<f32>, transform_offset: bool) {
let zero = Vec3d::ZERO.into();
let translation = matrix.transform_point(&zero) - zero;
let matrix = &matrix.append_translation(&(-translation));
let no_trans_matrix = &matrix.append_translation(&(-translation));

let subobj = &mut self.sub_objects[id];
subobj.radius = 0.0;
for vert in &mut subobj.bsp_data.verts {
*vert = matrix * *vert;
*vert = no_trans_matrix * *vert;
if !transform_offset {
*vert += translation.into();
}
Expand All @@ -2380,7 +2380,7 @@ impl Model {
}

// this preserves rotations, but inverts scales, which is the proper transformation for normals
let norm_matrix = matrix.try_inverse().unwrap().transpose();
let norm_matrix = no_trans_matrix.try_inverse().unwrap().transpose();

for norm in &mut subobj.bsp_data.norms {
*norm = (&norm_matrix * *norm).normalize();
Expand All @@ -2398,7 +2398,7 @@ impl Model {
let children = subobj.children.clone();

for child_id in children {
self.apply_subobj_transform(child_id, matrix, true)
self.apply_subobj_transform(child_id, no_trans_matrix, true)
}
}

Expand Down
1 change: 1 addition & 0 deletions src/ui_properties_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,7 @@ impl PofToolsGui {
rebuild_all_buffers = true;
self.ui_state.viewport_3d_dirty = true;
self.ui_state.properties_panel_dirty = true;
self.model.recheck_warnings(One(Warning::Detail0NonZeroOffset));
}

ui.add_space(10.0);
Expand Down

0 comments on commit a6c78ac

Please sign in to comment.