Skip to content

Commit

Permalink
Merge pull request scp-fs2open#5913 from Goober5000/5911_followup
Browse files Browse the repository at this point in the history
5911 followup
  • Loading branch information
Goober5000 authored Jan 3, 2024
2 parents a1690dc + f1a9b26 commit c9644cd
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions code/model/modelread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2886,6 +2886,8 @@ modelread_status read_model_file_no_subsys(polymodel * pm, const char* filename,

create_family_tree(pm);

// Now do submodel movement post-processing. This should come before all other error checking.

// ---------- submodel movement sanity checks ----------

for (i = 0; i < pm->n_models; i++) {
Expand Down Expand Up @@ -2931,6 +2933,16 @@ modelread_status read_model_file_no_subsys(polymodel * pm, const char* filename,
}
}

// And now look through all the submodels and set the model flag if any are intrinsic-moving
for (i = 0; i < pm->n_models; i++) {
if (pm->submodel[i].rotation_type == MOVEMENT_TYPE_INTRINSIC || pm->submodel[i].translation_type == MOVEMENT_TYPE_INTRINSIC) {
pm->flags |= PM_FLAG_HAS_INTRINSIC_MOTION;
break;
}
}

// -------------------- Now do any other error checking that validates data in the POF --------------------

// some dockpoint checks
for (i = 0; i < pm->n_docks; i++) {
auto dock = &pm->docking_bays[i];
Expand Down Expand Up @@ -2966,11 +2978,14 @@ modelread_status read_model_file_no_subsys(polymodel * pm, const char* filename,
}
}

// And now look through all the submodels and set the model flag if any are intrinsic-moving
for (i = 0; i < pm->n_models; i++) {
if (pm->submodel[i].rotation_type == MOVEMENT_TYPE_INTRINSIC || pm->submodel[i].translation_type == MOVEMENT_TYPE_INTRINSIC) {
pm->flags |= PM_FLAG_HAS_INTRINSIC_MOTION;
break;
// For several revisions, Pof Tools was writing invalid eyepoint data. We cannot guarantee that this will catch all instances,
// but should at least head off potential crashes before they happen
for (i = 0; i < pm->n_view_positions; ++i) {
if (pm->view_positions[i].parent < 0 || pm->view_positions[i].parent >= pm->n_models) {
nprintf(("Warning", "Model %s has an invalid eye position %i. Use a recent version of Pof Tools to fix the model.\n", pm->filename, i));
pm->view_positions[i].parent = 0;
pm->view_positions[i].norm = {{{1.0f, 0.0f, 0.0f}}};
pm->view_positions[i].pnt = ZERO_VECTOR;
}
}

Expand Down Expand Up @@ -3098,17 +3113,6 @@ modelread_status read_and_process_model_file(polymodel* pm, const char* filename
}
}

// For several revisions, poftools was writing invalid eyepoint data. We cannot guarantee that this will catch all instances,
// but should at least head off potential crashes before they happen
for (auto i = 0; i < pm->n_view_positions; ++i) {
if (pm->view_positions[i].parent < 0 || pm->view_positions[i].parent > pm->n_models) {
nprintf(("Warning", "Model %s has an invalid eye position %i. Use a recent version of poftools to fix the model", pm->filename, i));
pm->view_positions[i].parent = 0;
pm->view_positions[i].norm = {{{1.0f, 0.0f, 0.0f}}};
pm->view_positions[i].pnt = ZERO_VECTOR;
}
}

return status;
}

Expand Down

0 comments on commit c9644cd

Please sign in to comment.