Skip to content

Commit bb28c37

Browse files
authored
Merge pull request #3616 from Goober5000/look_at_updates
fixes to look_at and intrinsic rotation
2 parents 7bf7bf5 + ad2335c commit bb28c37

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

code/model/modelread.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,7 +1482,6 @@ int read_model_file(polymodel * pm, const char *filename, int n_subsystems, mode
14821482
// note, this should come BEFORE do_new_subsystem() for proper error handling (to avoid both rotating and look-at submodel)
14831483
if ((p = strstr(props, "$look_at")) != nullptr) {
14841484
pm->submodel[n].movement_type = MOVEMENT_TYPE_INTRINSIC_ROTATE;
1485-
pm->flags |= PM_FLAG_HAS_INTRINSIC_ROTATE;
14861485

14871486
// we need to work out the correct subobject number later, after all subobjects have been processed
14881487
pm->submodel[n].look_at_submodel = static_cast<int>(look_at_submodel_names.size());
@@ -1520,7 +1519,6 @@ int read_model_file(polymodel * pm, const char *filename, int n_subsystems, mode
15201519
int idx = prop_string(props, &p, "$dumb_rotate_time", "$dumb_rotate_rate", "$dumb_rotate");
15211520
if (idx >= 0) {
15221521
pm->submodel[n].movement_type = MOVEMENT_TYPE_INTRINSIC_ROTATE;
1523-
pm->flags |= PM_FLAG_HAS_INTRINSIC_ROTATE;
15241522

15251523
// do this the same way as regular $rotate
15261524
char buf[64];
@@ -2592,20 +2590,36 @@ int read_model_file(polymodel * pm, const char *filename, int n_subsystems, mode
25922590
}
25932591
}
25942592

2593+
// certain old models specify the submodel number, so let's maintain compatibilty
2594+
if (submodel_name != nullptr && can_construe_as_integer(submodel_name)) {
2595+
pm->submodel[i].look_at_submodel = atoi(submodel_name);
2596+
submodel_name = nullptr;
2597+
}
2598+
25952599
// did we fail to find it?
25962600
if (submodel_name != nullptr) {
25972601
Warning(LOCATION, "Unable to match %s %s $look_at: target %s with a submodel!\n", pm->filename, pm->submodel[i].name, submodel_name);
25982602
pm->submodel[i].look_at_submodel = -1;
2603+
pm->submodel[i].movement_type = MOVEMENT_TYPE_NONE;
25992604
}
26002605
// are we navel-gazing?
26012606
else if (pm->submodel[i].look_at_submodel == i) {
26022607
Warning(LOCATION, "Matched %s %s $look_at: target with its own submodel! Submodel cannot look at itself!\n", pm->filename, pm->submodel[i].name);
26032608
pm->submodel[i].look_at_submodel = -1;
2609+
pm->submodel[i].movement_type = MOVEMENT_TYPE_NONE;
26042610
}
26052611
}
26062612
}
26072613
}
26082614

2615+
// And now look through all the submodels and set the model flag if any are intrinsic-rotating
2616+
for (i = 0; i < pm->n_models; i++) {
2617+
if (pm->submodel[i].movement_type == MOVEMENT_TYPE_INTRINSIC_ROTATE) {
2618+
pm->flags |= PM_FLAG_HAS_INTRINSIC_ROTATE;
2619+
break;
2620+
}
2621+
}
2622+
26092623
#ifndef NDEBUG
26102624
if ( ss_fp) {
26112625
int size;

0 commit comments

Comments
 (0)