From 774c871c74ba921b778bb049130c70e84bb21a20 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Wed, 31 Jul 2019 15:19:40 +0200 Subject: [PATCH] sol:: basic shmup works --- hyper.h | 2 ++ hyperpoint.cpp | 10 ++++++++++ shmup.cpp | 18 +++++++++--------- sol.cpp | 18 ++++++++++++++++++ system.cpp | 3 --- 5 files changed, 39 insertions(+), 12 deletions(-) diff --git a/hyper.h b/hyper.h index 6fc2d3ad..9ca8606f 100644 --- a/hyper.h +++ b/hyper.h @@ -5636,6 +5636,8 @@ namespace solv { hyperpoint inverse_exp(hyperpoint h, bool lazy); transmatrix get_solmul(const transmatrix T, const transmatrix V); + transmatrix get_solmul_pt(const transmatrix Position, const transmatrix T); + transmatrix spin_towards(const transmatrix Position, const hyperpoint goal); extern string solshader; } diff --git a/hyperpoint.cpp b/hyperpoint.cpp index a56a2a7a..0e935cd5 100644 --- a/hyperpoint.cpp +++ b/hyperpoint.cpp @@ -796,4 +796,14 @@ transmatrix solmul(const transmatrix T, const transmatrix V) { else return T * V; } +transmatrix solmul_pt(const transmatrix Position, const transmatrix T) { + if(sol) return solv::get_solmul_pt(Position, T); + else return Position * T; + } + +transmatrix spin_towards(const transmatrix Position, const hyperpoint goal) { + if(sol) return solv::spin_towards(Position, goal); + return Position * rspintox(inverse(Position) * goal); + } + } diff --git a/shmup.cpp b/shmup.cpp index 78c458fd..54c4c325 100644 --- a/shmup.cpp +++ b/shmup.cpp @@ -1877,18 +1877,18 @@ void movePlayer(monster *m, int delta) { if(inertia_based) { if(igo) { go = false; break; } ld r = hypot_d(WDIM, avg_inertia); - nat = nat * rspintox(avg_inertia) * xpush(r * delta) * spintox(avg_inertia); + nat = solmul_pt(nat, rspintox(avg_inertia) * xpush(r * delta)) * spintox(avg_inertia); if(WDIM == 3) nat = nat * cspin(0, 2, playerturn[cpid]) * cspin(1, 2, playerturny[cpid]); m->vel = r * (600/SCALE); } else if(WDIM == 3) { - nat = nat1 * cpush(0, playerstrafe[cpid]) * cpush(2, playergo[cpid]) * cspin(0, 2, playerturn[cpid]) * cspin(1, 2, playerturny[cpid]); + nat = solmul_pt(nat1, cpush(0, playerstrafe[cpid]) * cpush(2, playergo[cpid])) * cspin(0, 2, playerturn[cpid]) * cspin(1, 2, playerturny[cpid]); m->inertia[0] = playerstrafe[cpid] / delta; m->inertia[1] = 0; m->inertia[2] = playergo[cpid] / delta; } else if(playergo[cpid]) { - nat = nat1 * spin(playergoturn[cpid]) * xpush(playergo[cpid]) * spin(-playergoturn[cpid]); + nat = solmul_pt(nat1, spin(playergoturn[cpid]) * xpush(playergo[cpid])) * spin(-playergoturn[cpid]); m->inertia = spin(playergoturn[cpid]) * xpush0(playergo[cpid] / delta); } @@ -2473,10 +2473,10 @@ void moveBullet(monster *m, int delta) { if(inertia_based) { ld r = hypot_d(WDIM, m->inertia); - nat = nat * rspintox(m->inertia) * xpush(r * delta) * spintox(m->inertia); + nat = solmul_pt(nat, rspintox(m->inertia) * xpush(r * delta) * spintox(m->inertia)); } else - nat = nat * frontpush(delta * SCALE * m->vel / speedfactor()); + nat = solmul_pt(nat, frontpush(delta * SCALE * m->vel / speedfactor())); cell *c2 = m->findbase(nat); if(m->parent && isPlayer(m->parent) && markOrb(itOrbLava) && c2 != m->base && !isPlayerOn(m->base)) @@ -2902,7 +2902,7 @@ void moveMonster(monster *m, int delta) { if(h[0] < fabsl(h[1])) return; } else if(!peace::on) { - nat = nat * rspintox(inverse(m->pat) * goal * C0); + nat = spin_towards(m->pat, tC0(goal)); } } @@ -2951,14 +2951,14 @@ void moveMonster(monster *m, int delta) { if(inertia_based) { if(igo) return; ld r = hypot_d(WDIM, m->inertia); - nat = nat * rspintox(m->inertia) * xpush(r * delta) * spintox(m->inertia); + nat = solmul_pt(nat, rspintox(m->inertia) * xpush(r * delta) * spintox(m->inertia)); } else if(WDIM == 3 && igo) { ld fspin = rand() % 1000; - nat = nat0 * cspin(1,2,fspin) * spin(igospan[igo]) * xpush(step) * spin(-igospan[igo]) * cspin(2,1,fspin); + nat = solmul_pt(nat0, cspin(1,2,fspin) * spin(igospan[igo]) * xpush(step) * spin(-igospan[igo]) * cspin(2,1,fspin)); } else { - nat = nat0 * spin(igospan[igo]) * xpush(step) * spin(-igospan[igo]); // * spintox(wherePC); + nat = solmul_pt(nat0, spin(igospan[igo]) * xpush(step) * spin(-igospan[igo])); // * spintox(wherePC); } if(m->type != moRagingBull && !peace::on) diff --git a/sol.cpp b/sol.cpp index a3fcfc89..d3715998 100644 --- a/sol.cpp +++ b/sol.cpp @@ -380,6 +380,24 @@ namespace solv { return space_to_view * npush * push_to; } + transmatrix get_solmul_pt(const transmatrix Position, const transmatrix T) { + return inverse(get_solmul(inverse(T), inverse(Position))); + } + + transmatrix spin_towards(const transmatrix Position, const hyperpoint goal) { + // Position * rspintox(inverse(Position) * goal); + // Position * rspintox(inverse(back_Position) * back_goal); + + hyperpoint at = tC0(Position); + transmatrix push_back = inverse(eupush(at)); + hyperpoint back_goal = push_back * goal; + back_goal = inverse_exp(back_goal, false); + + transmatrix back_Position = push_back * Position; + + return Position * rspintox(inverse(back_Position) * back_goal); + } + string solshader = "uniform mediump sampler3D tInvExpTable;" "uniform mediump float PRECX, PRECY, PRECZ;" diff --git a/system.cpp b/system.cpp index ebf56055..bbda8f32 100644 --- a/system.cpp +++ b/system.cpp @@ -1157,8 +1157,6 @@ void set_geometry(eGeometry target) { if(sol && old_DIM == 2) pmodel = mdSolPerspective; if(DIM == 2 && among(pmodel, mdPerspective, mdSolPerspective)) pmodel = mdDisk; if(sol && old_DIM == 2 && vid.texture_step < 4) vid.texture_step = 4; - - if(sol && shmup::on) shmup::on = false, racing::on = false; } } @@ -1278,7 +1276,6 @@ void switch_game_mode(char switchWhat) { shmup::on = !shmup::on; princess::challenge = false; if(!shmup::on) racing::on = false; - if(sol) set_geometry(gNormal); break; case rg::randpattern: