// File: /workspace/github_cpp_makefile_star2_O3/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 %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, 0x8(%rdi)
movq 0x8(%rsi), %rax
movq 0x18(%rax), %rax
movq (%rax), %rdi
leaq 0x192910(%rip), %r15    # 0x1c4558
movq %r15, %rsi
testq %rdi, %rdi
je 0x31c58
callq 0x4003c
movq %rax, %rsi
movq (%rsi), %rax
leaq 0x78(%rsp), %r12
movq %r12, %rdi
callq *0x68(%rax)
leaq 0x2b0(%rbx), %rdi
movq %r12, %rsi
callq 0xc409a
movabsq $0x4079000000000000, %rax # imm = 0x4079000000000000
movq %rax, 0x478(%rbx)
movq 0x8(%r14), %rax
movq 0x18(%rax), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x31c9e
callq 0x4003c
movq %rax, %r15
movq %r15, %rdi
callq 0xad918
mulsd 0x106362(%rip), %xmm0   # 0x138010
movsd 0x1066ea(%rip), %xmm1   # 0x1383a0
ucomisd %xmm0, %xmm1
jbe 0x31cf2
movq 0x8(%r14), %rax
movq 0x18(%rax), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x31cd6
callq 0x4003c
movq %rax, %rdi
jmp 0x31cdd
leaq 0x19287b(%rip), %rdi    # 0x1c4558
callq 0xad918
mulsd 0x106326(%rip), %xmm0   # 0x138010
movsd %xmm0, 0x478(%rbx)
movq 0x8(%r14), %rax
movq 0x18(%rax), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x31d0c
callq 0x4003c
movq %rax, %rsi
jmp 0x31d13
leaq 0x192845(%rip), %rsi    # 0x1c4558
leaq 0x40(%rsp), %r15
movq %r15, %rdi
callq 0xad2c4
movq %r15, %rdi
callq 0xad918
movsd %xmm0, 0x8(%rsp)
movb 0x18fcd4(%rip), %al     # 0x1c1a08
testb %al, %al
je 0x31e44
movb 0x18fce6(%rip), %al     # 0x1c1a28
testb %al, %al
je 0x31e84
movq 0x8(%r14), %rax
movq 0x18(%rax), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x31d64
callq 0x4003c
movq %rax, %rsi
jmp 0x31d6b
leaq 0x1927ed(%rip), %rsi    # 0x1c4558
movq (%rsi), %rax
leaq 0x78(%rsp), %rdi
callq *0x68(%rax)
movsd 0x8(%rsp), %xmm0
mulsd 0x10628c(%rip), %xmm0   # 0x138010
addsd %xmm0, %xmm0
leaq 0x18fc81(%rip), %rsi    # 0x1c1a10
leaq 0x10(%rsp), %rdi
callq 0xc5162
leaq 0x28(%rsp), %rdi
leaq 0x78(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0xc4753
leaq 0x18fc5c(%rip), %rdx    # 0x1c1a10
leaq 0x18fc35(%rip), %rcx    # 0x1c19f0
leaq 0x78(%rsp), %rdi
leaq 0x28(%rsp), %rsi
movsd 0x106253(%rip), %xmm0   # 0x138020
movsd 0x106253(%rip), %xmm2   # 0x138028
movsd 0x106253(%rip), %xmm3   # 0x138030
movapd %xmm0, %xmm1
callq 0x79f14
movl 0x494(%rbx), %r8d
movl 0x498(%rbx), %ecx
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x7ac4a
leaq 0x78(%rbx), %r14
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x7865e
leaq 0x78(%rsp), %rsi
movq %r14, %rdi
callq 0x78604
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x310(%rax)
leaq 0x40(%rsp), %rdi
callq 0xae0e4
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x18fbbd(%rip), %rdi    # 0x1c1a08
callq 0x28190
testl %eax, %eax
je 0x31d3c
leaq 0x18fb91(%rip), %rdi    # 0x1c19f0
movsd 0x1061a1(%rip), %xmm1   # 0x138008
xorpd %xmm0, %xmm0
xorps %xmm2, %xmm2
callq 0xc47c6
leaq 0x18fb8e(%rip), %rdi    # 0x1c1a08
callq 0x275f0
jmp 0x31d3c
leaq 0x18fb9d(%rip), %rdi    # 0x1c1a28
callq 0x28190
testl %eax, %eax
je 0x31d4a
leaq 0x18fb71(%rip), %rdi    # 0x1c1a10
movsd 0x106191(%rip), %xmm2   # 0x138038
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
callq 0xc47c6
leaq 0x18fb6d(%rip), %rdi    # 0x1c1a28
callq 0x275f0
jmp 0x31d4a
movq %rax, %rbx
leaq 0x18fb59(%rip), %rdi    # 0x1c1a28
jmp 0x31edb
movq %rax, %rbx
leaq 0x18fb2d(%rip), %rdi    # 0x1c1a08
callq 0x275d0
jmp 0x31eed
jmp 0x31eea
jmp 0x31eea
jmp 0x31eea
jmp 0x31eea
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0xae0e4
movq %rbx, %rdi
callq 0x28120
nop