Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A flag that checks if set-camera-host sexp should use the model's eyepoint for the camera position when no submodel is specified #6540

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
18 changes: 18 additions & 0 deletions code/camera/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,24 @@ void camera::set_rotation_facing(vec3d *in_target, float in_rotation_time, float
matrix orient_buf;
matrix *orient = nullptr;

if (Use_model_eyepoint_for_set_camera_facing) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the wrong place for the change in behavior. Since the flag is supposed to modify the functionality of set-camera-host, take a look at that sexp implementation and the functions called by it.

(If you still need help after that hint, I can give more specific information.)

if (object_host.isValid()) {
object* host = object_host.objp();

if (host->type == OBJ_SHIP) {
ship_info* sip;
polymodel* pm;

ship* shipmodel = &Ships[host->instance];
sip = &Ship_info[shipmodel->ship_info_index];
pm = model_get(sip->model_num);
const eye& eyepoint = pm->view_positions[shipmodel->current_viewpoint];

model_instance_local_to_global_point(&position, &eyepoint.pnt, shipmodel->model_instance_num, eyepoint.parent, &host->orient, &host->pos);
}
}
}

if (Use_host_orientation_for_set_camera_facing)
{
// we want to retrieve the camera's orientation, so provide a buffer for it
Expand Down
9 changes: 9 additions & 0 deletions code/mod_table/mod_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ bool Cutscene_camera_displays_hud;
bool Alternate_chaining_behavior;
bool Fixed_chaining_to_repeat;
bool Use_host_orientation_for_set_camera_facing;
bool Use_model_eyepoint_for_set_camera_facing;
bool Use_3d_ship_select;
bool Use_3d_ship_icons;
bool Use_3d_weapon_select;
Expand Down Expand Up @@ -502,6 +503,12 @@ void parse_mod_table(const char *filename)
}
}

if (optional_string("$Use model eyepoint for set-camera-facing:")) {
stuff_boolean(&Use_model_eyepoint_for_set_camera_facing);
if (Use_model_eyepoint_for_set_camera_facing) {
Copy link
Contributor

Choose a reason for hiding this comment

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

There is an opening brace at the end of this line without a closing brace. An if that contains a single line doesn't need braces, but if you add them, there needs to be a pair.

mprintf(("Game Settings Table: Using model eyepoint for set-camera-facing\n"));
}

if (optional_string("$Show-subtitle uses pixels:")) {
stuff_boolean(&Show_subtitle_uses_pixels);
if (Show_subtitle_uses_pixels) {
Expand Down Expand Up @@ -1527,6 +1534,7 @@ void mod_table_reset()
Alternate_chaining_behavior = false;
Fixed_chaining_to_repeat = false;
Use_host_orientation_for_set_camera_facing = false;
Use_model_eyepoint_for_set_camera_facing = false;
Default_ship_select_effect = 2;
Default_weapon_select_effect = 2;
Default_overhead_ship_style = OH_TOP_VIEW;
Expand Down Expand Up @@ -1667,6 +1675,7 @@ void mod_table_set_version_flags()
Shockwaves_damage_all_obj_types_once = true;
Framerate_independent_turning = true; // this is already true, but let's re-emphasize it
Use_host_orientation_for_set_camera_facing = true; // this is essentially a bugfix
Use_model_eyepoint_for_set_camera_facing = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

It's good to add this flag as a bugfix, as you did here, but it's in the wrong section. Any new flags added should be associated with the upcoming stable version, so this should be added in the 25.0.0 section. (Currently, that section doesn't exist, so you'll need to create it.)

}
if (mod_supports_version(23, 0, 0)) {
Shockwaves_inherit_parent_damage_type = true; // people intuitively expect shockwaves to default to the damage type of the weapon that spawned them
Expand Down
1 change: 1 addition & 0 deletions code/mod_table/mod_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ extern bool Cutscene_camera_displays_hud;
extern bool Alternate_chaining_behavior;
extern bool Fixed_chaining_to_repeat;
extern bool Use_host_orientation_for_set_camera_facing;
extern bool Use_model_eyepoint_for_set_camera_facing;
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the issue you are addressing is to use the model eyepoint for set-camera-host, both the variable and the text parsed in game_settings.tbl should refer to set-camera-host, not set-camera-facing.

extern bool Use_3d_ship_select;
extern int Default_ship_select_effect;
extern bool Use_3d_ship_icons;
Expand Down
Loading