From cd04b3f8e8024ddc533e37c22f74c8f3f8a202ca Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 6 Oct 2019 11:56:19 +0200 Subject: [PATCH] precision argument for parallel_transport, and reducing it when used many times --- hyperpoint.cpp | 4 ++-- shmup.cpp | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/hyperpoint.cpp b/hyperpoint.cpp index ce128b39..7ee51ac0 100644 --- a/hyperpoint.cpp +++ b/hyperpoint.cpp @@ -996,13 +996,13 @@ EX bool asign(ld y1, ld y2) { return signum(y1) != signum(y2); } EX ld xcross(ld x1, ld y1, ld x2, ld y2) { return x1 + (x2 - x1) * y1 / (y1 - y2); } -EX transmatrix parallel_transport(const transmatrix Position, const transmatrix& ori, const hyperpoint direction) { +EX transmatrix parallel_transport(const transmatrix Position, const transmatrix& ori, const hyperpoint direction, int precision IS(100)) { if(nonisotropic) return nisot::parallel_transport(Position, direction); else if(prod) { hyperpoint h = product::direct_exp(ori * direction); return Position * rgpushxto0(h); } - else return Position * rgpushxto0(direct_exp(direction, 100)); + else return Position * rgpushxto0(direct_exp(direction, precision)); } EX void apply_parallel_transport(transmatrix& Position, const transmatrix orientation, const hyperpoint direction) { diff --git a/shmup.cpp b/shmup.cpp index 7654aa8e..aa5c5228 100644 --- a/shmup.cpp +++ b/shmup.cpp @@ -1107,7 +1107,7 @@ void movePlayer(monster *m, int delta) { int i0 = i; for(int a=0; a<3; a++) v[a] = (i0 % 3) - 1, i0 /= 3; v = v * .1 / hypot_d(3, v); - transmatrix T1 = (i == 13) ? nat : parallel_transport(nat, m->ori, v); + transmatrix T1 = (i == 13) ? nat : parallel_transport(nat, m->ori, v, 2); cell *c3 = c2; while(true) { cell *c4 = findbaseAround(tC0(T1), c3, 1); @@ -1634,10 +1634,10 @@ void moveBullet(monster *m, int delta) { m->dead = true; if(inertia_based) { - nat = parallel_transport(nat, m->ori, m->inertia * delta); + nat = parallel_transport(nat, m->ori, m->inertia * delta, 10); } else - nat = parallel_transport(nat, m->ori, fronttangent(delta * SCALE * m->vel / speedfactor())); + nat = parallel_transport(nat, m->ori, fronttangent(delta * SCALE * m->vel / speedfactor()), 10); cell *c2 = m->findbase(nat, 1); if(m->parent && isPlayer(m->parent) && markOrb(itOrbLava) && c2 != m->base && !isPlayerOn(m->base)) @@ -2111,14 +2111,14 @@ void moveMonster(monster *m, int delta) { if(inertia_based) { if(igo) return; - nat = parallel_transport(nat, m->ori, m->inertia * delta); + nat = parallel_transport(nat, m->ori, m->inertia * delta, 10); } else if(WDIM == 3 && igo) { ld fspin = rand() % 1000; - nat = parallel_transport(nat0, m->ori, cspin(1,2,fspin) * spin(igospan[igo]) * xtangent(step)); + nat = parallel_transport(nat0, m->ori, cspin(1,2,fspin) * spin(igospan[igo]) * xtangent(step), 10); } else { - nat = parallel_transport(nat0, m->ori, spin(igospan[igo]) * xtangent(step)); + nat = parallel_transport(nat0, m->ori, spin(igospan[igo]) * xtangent(step), 10); } if(m->type != moRagingBull && !peace::on)