centering/TPP/camera cleanup

This commit is contained in:
Zeno Rogue 2019-05-11 23:52:18 +02:00
parent 5fbdeaa89d
commit 44194bd354
3 changed files with 20 additions and 31 deletions

View File

@ -1255,7 +1255,7 @@ void show3D() {
}
if(WDIM == 2) {
dialog::addSelItem(XLAT("Camera level above the plane"), fts3(camera), 'c');
dialog::addSelItem(XLAT(GDIM == 2 ? "Camera level above the plane" : "Z shift"), fts3(camera), 'c');
dialog::addSelItem(XLAT("Ground level below the plane"), fts3(depth), 'g');
dialog::addSelItem(XLAT("Projection at the ground level"), fts3(vid.alpha), 'a');
@ -1274,7 +1274,7 @@ void show3D() {
}
dialog::addBreak(50);
dialog::addSelItem(XLAT(DIM == 2 ? "Y shift" : "third person perspective"), fts3(vid.yshift), 'y');
dialog::addSelItem(XLAT(DIM == 3 && WDIM == 2 ? "Y shift" : "third person perspective"), fts3(vid.yshift), 'y');
if(DIM == 3) {
dialog::addSelItem(XLAT("mouse aiming sensitivity"), fts(mouseaim_sensitivity), 'a');
dialog::add_action([] () {
@ -1366,10 +1366,10 @@ void show3D() {
}
else if(uni == 'c' && WDIM == 2)
tc_camera = ticks,
dialog::editNumber(geom3::camera, 0, 5, .1, 1, XLAT("Camera level above the plane"), ""),
dialog::editNumber(geom3::camera, 0, 5, .1, 1, XLAT(GDIM == 2 ? "Camera level above the plane" : "Z shift"), ""),
dialog::reaction = [] { if(GDIM == 2) need_reset_geometry = true; },
dialog::extra_options = [] {
dialog::addHelp(XLAT(
dialog::addHelp(GDIM == 2 ? XLAT(
"Camera is placed %1 absolute units above a plane P in a three-dimensional "
"world. Ground level is actually an equidistant surface, %2 absolute units "
"below the plane P. The plane P (as well as the ground level or any "
@ -1379,7 +1379,10 @@ void show3D() {
fts3(camera),
fts3(depth),
fts3(atan(1/cosh(camera))*2/degree),
fts3(1/cosh(camera))));
fts3(1/cosh(camera))) : XLAT("Look from behind."));
if(DIM == 3 && pmodel == mdPerspective) dialog::extra_options = [] () {
dialog::addBoolItem_action(XLAT("reduce if walls on the way"), vid.use_wall_radar, 'R');
};
};
else if(uni == 'g' && WDIM == 2)
tc_depth = ticks,
@ -1464,7 +1467,7 @@ void show3D() {
dialog::editNumber(vid.yshift, 0, 1, .1, 0, XLAT("Y shift"),
XLAT("Don't center on the player character.")
);
if(DIM == 3) dialog::extra_options = [] () {
if(WDIM == 3 && pmodel == mdPerspective) dialog::extra_options = [] () {
dialog::addBoolItem_action(XLAT("reduce if walls on the way"), vid.use_wall_radar, 'R');
};
}

View File

@ -6262,15 +6262,15 @@ purehookset hooks_drawmap;
transmatrix actual_view_transform;
ld wall_radar(cell *c, transmatrix T) {
if(!vid.use_wall_radar) return vid.yshift;
ld wall_radar(cell *c, transmatrix T, ld max) {
if(pmodel != mdPerspective || !vid.use_wall_radar) return max;
ld step = max / 20;
ld fixed_yshift = 0;
ld step = vid.yshift / 20;
for(int i=0; i<20; i++) {
T = T * cpush(2, -step);
virtualRebase(c, T, false);
color_t col;
if(isWall3(c, col)) {
if(isWall3(c, col) || (WDIM == 2 && GDIM == 3 && tC0(T)[2] > geom3::FLOOR)) {
T = T * cpush(2, step);
step /= 2; i = 17;
if(step < 1e-3) break;
@ -6282,17 +6282,15 @@ ld wall_radar(cell *c, transmatrix T) {
void make_actual_view() {
sphereflip = Id;
#if MAXMDIM >= 4
if(WDIM == 3 && !shmup::on && vid.yshift) {
actual_view_transform = cpush(2, wall_radar(viewctr.at->c7, inverse(View)));
return;
}
if(WDIM == 3) { actual_view_transform = Id; return; }
#endif
if(sphereflipped()) sphereflip[DIM][DIM] = -1;
actual_view_transform = ypush(vid.yshift) * sphereflip;
actual_view_transform = sphereflip;
if(vid.yshift && WDIM == 2) actual_view_transform = ypush(vid.yshift) * actual_view_transform;
#if MAXMDIM >= 4
if(geom3::always3) actual_view_transform = zpush(+geom3::camera) * actual_view_transform;
if(GDIM == 3) {
ld max = WDIM == 2 ? geom3::camera : vid.yshift;
if(max)
actual_view_transform = zpush(wall_radar(viewctr.at->c7, inverse(View), max)) * actual_view_transform;
}
#endif
}

View File

@ -1100,19 +1100,7 @@ void centerpc(ld aspd) {
int sl = snakelevel(cwt.at);
if(sl) T = T * zpush(geom3::SLEV[sl] - geom3::FLOOR);
View = inverse(T);
if(vid.yshift) View = cpush(2, wall_radar(viewctr.at->c7, T)) * View;
if(WDIM == 2) View = cspin(0, 1, M_PI) * cspin(2, 1, M_PI/2 + shmup::playerturny[id]) * spin(-M_PI/2) * View;
#if CAP_RACING
if(racing::on) racing::set_view();
#endif
return;
}
#endif
#if CAP_RACING
if(racing::on && !racing::standard_centering) {
racing::set_view();
return;
}
#endif