// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Utils/R3SurfelViewer.cpp
// Function: gaps::R3SurfelViewer::SetScene(gaps::R3SurfelScene*)
void R3SurfelViewer::
SetScene(R3SurfelScene *scene)
{
  // Remember scene
  this->scene = scene;

  // Set center point
  center_point = scene->Centroid();
  // center_point[1] = scene->BBox().YMin();

  // Set focus radius
  focus_radius = 400;
  if (focus_radius > scene->BBox().DiagonalRadius()) {
    focus_radius = scene->BBox().DiagonalRadius();
  }

  // Set camera and viewport
  R3Box bbox = scene->BBox();
  RNLength r = bbox.DiagonalRadius();
  static const R3Vector up(0, 1, 0);
  static const R3Vector towards(0, 0, -1);
  R3Point eye = scene->Centroid() - towards * (2 * r); 
  R3Camera camera(eye, towards, up, 0.4, 0.4, 0.01, 100000.0);
  R2Viewport viewport(0, 0, window_width, window_height);
  viewer.SetViewport(viewport);
  viewer.SetCamera(camera);

  // Lock coarsest blocks in memory (~500MB)
  // ReadCoarsestBlocks(1 * 1024 * 1024);

  // Update ground z grid
  // UpdateGroundZGrid();

  // Update working set
  UpdateWorkingSet();
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x100, %rsp            # imm = 0x100
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, 0x8(%rdi)
leaq 0x70(%rsp), %r15
movq %r15, %rdi
callq 0x32c38
leaq 0x2b0(%rbx), %rdi
movq %r15, %rsi
callq 0xb260a
movabsq $0x4079000000000000, %rax # imm = 0x4079000000000000
movq %rax, 0x478(%rbx)
movq %r14, %rdi
callq 0x32960
movq %rax, %rdi
callq 0x32b1a
movsd 0xe9def(%rip), %xmm1    # 0x11a3a0
ucomisd %xmm0, %xmm1
jbe 0x305cf
movq %r14, %rdi
callq 0x32960
movq %rax, %rdi
callq 0x32b1a
movsd %xmm0, 0x478(%rbx)
movq %r14, %rdi
callq 0x32960
leaq 0x38(%rsp), %r15
movq %r15, %rdi
movq %rax, %rsi
callq 0x9de5a
movq %r15, %rdi
callq 0x32b1a
movsd %xmm0, (%rsp)
movb 0x17c42e(%rip), %al     # 0x1aca28
testb %al, %al
je 0x306e0
movb 0x17c440(%rip), %al     # 0x1aca48
testb %al, %al
je 0x30720
leaq 0x70(%rsp), %rdi
movq %r14, %rsi
callq 0x32c38
movsd (%rsp), %xmm0
addsd %xmm0, %xmm0
leaq 0x17c403(%rip), %rsi    # 0x1aca30
leaq 0x8(%rsp), %rdi
callq 0xb31d6
leaq 0x20(%rsp), %rdi
leaq 0x70(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0xb2a71
leaq 0x17c3de(%rip), %rdx    # 0x1aca30
leaq 0x17c3b7(%rip), %rcx    # 0x1aca10
leaq 0x70(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movsd 0xe99b5(%rip), %xmm0    # 0x11a020
movsd 0xe99b5(%rip), %xmm2    # 0x11a028
movsd 0xe99b5(%rip), %xmm3    # 0x11a030
movapd %xmm0, %xmm1
callq 0x700ee
movl 0x494(%rbx), %r8d
movl 0x498(%rbx), %ecx
leaq 0x8(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x70ce8
leaq 0x78(%rbx), %r14
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x6e94c
leaq 0x70(%rsp), %rsi
movq %r14, %rdi
callq 0x6e8f2
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x310(%rax)
leaq 0x38(%rsp), %rdi
callq 0x9eb12
addq $0x100, %rsp            # imm = 0x100
popq %rbx
popq %r14
popq %r15
retq
leaq 0x17c341(%rip), %rdi    # 0x1aca28
callq 0x281b0
testl %eax, %eax
je 0x30602
leaq 0x17c315(%rip), %rdi    # 0x1aca10
movsd 0xe9905(%rip), %xmm1    # 0x11a008
xorpd %xmm0, %xmm0
xorps %xmm2, %xmm2
callq 0xb2ae0
leaq 0x17c312(%rip), %rdi    # 0x1aca28
callq 0x275f0
jmp 0x30602
leaq 0x17c321(%rip), %rdi    # 0x1aca48
callq 0x281b0
testl %eax, %eax
je 0x30610
leaq 0x17c2f5(%rip), %rdi    # 0x1aca30
movsd 0xe98f5(%rip), %xmm2    # 0x11a038
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
callq 0xb2ae0
leaq 0x17c2f1(%rip), %rdi    # 0x1aca48
callq 0x275f0
jmp 0x30610
movq %rax, %rbx
leaq 0x17c2dd(%rip), %rdi    # 0x1aca48
jmp 0x30777
movq %rax, %rbx
leaq 0x17c2b1(%rip), %rdi    # 0x1aca28
callq 0x275d0
jmp 0x30789
jmp 0x30786
jmp 0x30786
jmp 0x30786
jmp 0x30786
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x9eb12
movq %rbx, %rdi
callq 0x28140
nop