Skip to content
Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions code/model/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,7 @@ typedef struct insignia {
#define PM_FLAG_AUTOCEN (1<<1) // contains autocentering info
#define PM_FLAG_TRANS_BUFFER (1<<2) // render transparency buffer
#define PM_FLAG_BATCHED (1<<3) // this model can be batch rendered
#define PM_FLAGS_HAS_LOOK_AT (1<<4) // this model has a submodel that does look_at

// Goober5000
class texture_info
Expand Down
4 changes: 4 additions & 0 deletions code/model/modelinterp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2011,6 +2011,10 @@ void model_render_DEPRECATED(int model_num, matrix *orient, vec3d * pos, uint fl

polymodel *pm = model_get(model_num);

if (pm->flags & PM_FLAGS_HAS_LOOK_AT) {
model_do_look_at(model_num);
}

model_do_dumb_rotation(model_num);

if (flags & MR_FORCE_CLAMP)
Expand Down
19 changes: 10 additions & 9 deletions code/model/modelread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1216,19 +1216,12 @@ int read_model_file(polymodel * pm, char *filename, int n_subsystems, model_subs
}
}

// Sets can_move on submodels which are of a rotating type or which have such a parent somewhere down the hierarchy
if ( (pm->submodel[n].movement_type != MOVEMENT_TYPE_NONE)
|| strstr(props, "$triggered:") || strstr(props, "$rotate") || strstr(props, "$dumb_rotate:") || strstr(props, "$gun_rotation:") || strstr(props, "$gun_rotation") ) {
pm->submodel[n].can_move = true;
} else if (pm->submodel[n].parent > -1 && pm->submodel[pm->submodel[n].parent].can_move) {
pm->submodel[n].can_move = true;
}

if ( ( p = strstr(props, "$look_at:")) != NULL ) {
pm->submodel[n].movement_type = MOVEMENT_TYPE_LOOK_AT;
get_user_prop_value(p+9, pm->submodel[n].look_at);
pm->submodel[n].look_at_num = -2; // Set this to -2 to mark it as something we need to work out the correct subobject number for later, after all subobjects have been processed

pm->flags |= PM_FLAGS_HAS_LOOK_AT;
} else {
pm->submodel[n].look_at_num = -1; // No look_at
}
Expand All @@ -1240,6 +1233,14 @@ int read_model_file(polymodel * pm, char *filename, int n_subsystems, model_subs
pm->submodel[n].dumb_turn_rate = 0.0f;
}

// Sets can_move on submodels which are of a rotating type or which have such a parent somewhere down the hierarchy
if ( (pm->submodel[n].movement_type != MOVEMENT_TYPE_NONE)
|| strstr(props, "$triggered:") || strstr(props, "$rotate") || strstr(props, "$gun_rotation:") || strstr(props, "$gun_rotation") ) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Did you mean to remove one of the two $gun_rotation checks? I notice that there are two duplicate checks but the $dumb_rotate check is missing.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I suppose the $gun_rotation: check is redundant with the $gun_rotation check, but I intentionally removed the $dumb_rotate check because it's made irrelevant by moving this check to below where $dumb_rotate is handled.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think so; the $dumb_rotate block doesn't assign pm->submodel[n].can_move = true;.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It doesn't need to; it sets movement_type to something other than MOVEMENT_TYPE_NONE so this block (setting can_move) still executes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah, I missed the movement_type clause in the condition. Fair enough.

pm->submodel[n].can_move = true;
} else if (pm->submodel[n].parent > -1 && pm->submodel[pm->submodel[n].parent].can_move) {
pm->submodel[n].can_move = true;
}

if ( pm->submodel[n].name[0] == '\0' ) {
strcpy_s(pm->submodel[n].name, "unknown object name");
}
Expand Down Expand Up @@ -3481,7 +3482,7 @@ void submodel_look_at(polymodel *pm, int mn)
}

if (sm->look_at_num == -2) {
Warning( LOCATION, "Invalid submodel name given in $look_at: property in model file <%s>. (%s looking for %s)\n", pm->filename, pm->submodel->name, sm->look_at );
Warning( LOCATION, "Invalid submodel name given in $look_at: property in model file <%s>. (%s looking for %s)\n", pm->filename, sm->name, sm->look_at );
sm->look_at_num = -1; // Set to -1 to not break stuff
}
}
Expand Down
4 changes: 4 additions & 0 deletions code/model/modelrender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2670,6 +2670,10 @@ void model_render_queue(model_render_params *interp, draw_list *scene, int model
const int model_flags = interp->get_model_flags();

polymodel *pm = model_get(model_num);

if (pm->flags & PM_FLAGS_HAS_LOOK_AT) {
model_do_look_at(model_num);
}

model_do_dumb_rotation(model_num);

Expand Down