// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/GSV/GSVPanorama.cpp
// Function: gaps::GSVPanorama::UpdatePose()
void GSVPanorama::
UpdatePose(void) 
{
  // Update viewpoint
  if (viewpoint[0] == FLT_MAX) {
    viewpoint = R3zero_point;
    if (NImages() > 0) {
      for (int i = 0; i < NImages(); i++) 
        viewpoint += Image(i)->Pose().Viewpoint();
      viewpoint /= NImages();
    }
  }

  // Update front vector
  if (front == R3zero_vector) {
    if ((NImages() == 7) || (NImages() == 6)) {
      // Herschel (with or without sky camera)
      front = R3posz_vector % Image(1)->Pose().Towards();
      front.Normalize();
    }
    else if ((NImages() == 9) || (NImages() == 8)) {
      // R7 (with or without sky camera)
      front = Image(0)->Pose().Towards();
      front[2] = 0;
      front.Normalize();
    }
    else if (Segment() && (SegmentIndex() > 0) && (viewpoint[0] != FLT_MAX)) {
      // Based on viewpoint change from previous panorama
      GSVPanorama *panoramaA = Segment()->Panorama(SegmentIndex()-1);
      R3Point viewpointA = panoramaA->Viewpoint();
      if (viewpointA[0] != FLT_MAX) {
        front = viewpoint - viewpointA;
        front[2] = 0;
        front.Normalize();
      }
    }
    else if (Segment() && (SegmentIndex() < Segment()->NPanoramas()-1) && (viewpoint[0] != FLT_MAX)) {
      // Based on viewpoint change from next panorama
      GSVPanorama *panoramaB = Segment()->Panorama(SegmentIndex()+1);
      R3Point viewpointB = panoramaB->Viewpoint();
      if (viewpointB[0] != FLT_MAX) {
        front = viewpointB - viewpoint;
        front[2] = 0;
        front.Normalize();
      }
    }
  }

  // Update right vector
  if (right == R3zero_vector) {
    right = front % Up();
    right.Normalize();
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x70, %rsp
movq %rdi, %rbx
leaq 0x28(%rdi), %r15
movsd 0x28(%rdi), %xmm0
ucomisd 0x111079(%rip), %xmm0   # 0x14e008
jne 0x3cfff
jp 0x3cfff
leaq 0x5a46b6(%rip), %rsi    # 0x5e1650
movq %r15, %rdi
callq 0xd619c
cmpl $0x0, 0x24(%rbx)
jle 0x3cfff
movl 0x24(%rbx), %eax
testl %eax, %eax
jle 0x3cff0
leaq 0x20(%rsp), %r14
xorl %r13d, %r13d
leaq 0x18(%rsp), %r12
movq 0x18(%rbx), %rax
movq (%rax,%r13,8), %rsi
movq %r12, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x3d698
movq %r15, %rdi
movq %r14, %rsi
callq 0xd676e
movq %r12, %rdi
callq 0x455ba
incq %r13
movslq 0x24(%rbx), %rax
cmpq %rax, %r13
jl 0x3cfbc
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movq %r15, %rdi
callq 0xd67ec
leaq 0x40(%rbx), %r14
leaq 0x11bd36(%rip), %rsi    # 0x158d40
movq %r14, %rdi
callq 0xd6b84
testl %eax, %eax
je 0x3d0cc
movl 0x24(%rbx), %eax
leal -0x8(%rax), %ecx
cmpl $0x2, %ecx
jb 0x3d083
addl $-0x6, %eax
cmpl $0x1, %eax
ja 0x3d129
movq 0x18(%rbx), %rax
movq 0x8(%rax), %rsi
leaq 0x18(%rsp), %r15
movq %r15, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x3d698
leaq 0x58(%rsp), %rdi
movq %r15, %rsi
callq 0x455c6
leaq 0x11bd41(%rip), %rsi    # 0x158da0
movq %rsp, %rdi
leaq 0x58(%rsp), %rdx
callq 0xd721a
movq %rsp, %rsi
movq %r14, %rdi
callq 0xd7072
leaq 0x18(%rsp), %rdi
callq 0x455ba
jmp 0x3d0c4
movq 0x18(%rbx), %rax
movq (%rax), %rsi
leaq 0x18(%rsp), %r15
movq %r15, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x3d698
movq %rsp, %rdi
movq %r15, %rsi
callq 0x455c6
movq %rsp, %rsi
movq %r14, %rdi
callq 0xd7072
leaq 0x18(%rsp), %rdi
callq 0x455ba
movq $0x0, 0x50(%rbx)
movq %r14, %rdi
callq 0xd6be8
addq $0x58, %rbx
leaq 0x11bc69(%rip), %rsi    # 0x158d40
movq %rbx, %rdi
callq 0xd6b84
testl %eax, %eax
je 0x3d11b
leaq 0x11bcb6(%rip), %rsi    # 0x158da0
movq %rsp, %r15
movq %r15, %rdi
callq 0xd68d6
leaq 0x18(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0xd721a
movq %rbx, %rdi
movq %r12, %rsi
callq 0xd7072
movq %rbx, %rdi
callq 0xd6be8
addq $0x70, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x3d0cc
movslq 0x10(%rbx), %rcx
testq %rcx, %rcx
jle 0x3d190
movsd 0x28(%rbx), %xmm0
ucomisd 0x110ec0(%rip), %xmm0   # 0x14e008
jne 0x3d14c
jnp 0x3d190
movq 0x40(%rax), %rax
movq -0x8(%rax,%rcx,8), %rdi
callq 0x3d294
leaq 0x18(%rsp), %r12
movq %r12, %rdi
movq %rax, %rsi
callq 0xd5e3e
movsd (%r12), %xmm0
ucomisd 0x110e90(%rip), %xmm0   # 0x14e008
jne 0x3d180
jnp 0x3d0cc
movq %rsp, %r12
leaq 0x18(%rsp), %rdx
movq %r12, %rdi
movq %r15, %rsi
jmp 0x3d201
testq %rax, %rax
je 0x3d0cc
movslq 0x10(%rbx), %rcx
movl 0x4c(%rax), %edx
decl %edx
cmpl %edx, %ecx
jge 0x3d0cc
movsd 0x28(%rbx), %xmm0
ucomisd 0x110e51(%rip), %xmm0   # 0x14e008
jne 0x3d1bf
jnp 0x3d0cc
movq 0x40(%rax), %rax
movq 0x8(%rax,%rcx,8), %rdi
callq 0x3d294
leaq 0x18(%rsp), %r12
movq %r12, %rdi
movq %rax, %rsi
callq 0xd5e3e
movsd (%r12), %xmm0
ucomisd 0x110e1d(%rip), %xmm0   # 0x14e008
jne 0x3d1f3
jnp 0x3d0cc
movq %rsp, %r12
leaq 0x18(%rsp), %rsi
movq %r12, %rdi
movq %r15, %rdx
callq 0xd6090
movq %r14, %rdi
movq %r12, %rsi
callq 0xd7072
jmp 0x3d0bc
jmp 0x3d21a
jmp 0x3d21a
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x455ba
movq %rbx, %rdi
callq 0x28160
nop