// File: /workspace/github_cpp_makefile_star2_O1/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 0x1957a8(%rip), %r15    # 0x1c7558
movq %r15, %rsi
testq %rdi, %rdi
je 0x31dc0
callq 0x3ff5c
movq %rax, %rsi
movq (%rsi), %rax
leaq 0x78(%rsp), %r12
movq %r12, %rdi
callq *0x68(%rax)
leaq 0x2b0(%rbx), %rdi
movq %r12, %rsi
callq 0xc568c
movabsq $0x4079000000000000, %rax # imm = 0x4079000000000000
movq %rax, 0x478(%rbx)
movq 0x8(%r14), %rax
movq 0x18(%rax), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x31e06
callq 0x3ff5c
movq %rax, %r15
movq %r15, %rdi
callq 0xaeba8
mulsd 0x1091fa(%rip), %xmm0   # 0x13b010
movsd 0x109582(%rip), %xmm1   # 0x13b3a0
ucomisd %xmm0, %xmm1
jbe 0x31e5a
movq 0x8(%r14), %rax
movq 0x18(%rax), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x31e3e
callq 0x3ff5c
movq %rax, %rdi
jmp 0x31e45
leaq 0x195713(%rip), %rdi    # 0x1c7558
callq 0xaeba8
mulsd 0x1091be(%rip), %xmm0   # 0x13b010
movsd %xmm0, 0x478(%rbx)
movq 0x8(%r14), %rax
movq 0x18(%rax), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x31e74
callq 0x3ff5c
movq %rax, %rsi
jmp 0x31e7b
leaq 0x1956dd(%rip), %rsi    # 0x1c7558
leaq 0x40(%rsp), %r15
movq %r15, %rdi
callq 0xae528
movq %r15, %rdi
callq 0xaeba8
movsd %xmm0, 0x8(%rsp)
movb 0x192b6c(%rip), %al     # 0x1c4a08
testb %al, %al
je 0x31fac
movb 0x192b7e(%rip), %al     # 0x1c4a28
testb %al, %al
je 0x31fec
movq 0x8(%r14), %rax
movq 0x18(%rax), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x31ecc
callq 0x3ff5c
movq %rax, %rsi
jmp 0x31ed3
leaq 0x195685(%rip), %rsi    # 0x1c7558
movq (%rsi), %rax
leaq 0x78(%rsp), %rdi
callq *0x68(%rax)
movsd 0x8(%rsp), %xmm0
mulsd 0x109124(%rip), %xmm0   # 0x13b010
addsd %xmm0, %xmm0
leaq 0x192b19(%rip), %rsi    # 0x1c4a10
leaq 0x10(%rsp), %rdi
callq 0xc6786
leaq 0x28(%rsp), %rdi
leaq 0x78(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0xc5d45
leaq 0x192af4(%rip), %rdx    # 0x1c4a10
leaq 0x192acd(%rip), %rcx    # 0x1c49f0
leaq 0x78(%rsp), %rdi
leaq 0x28(%rsp), %rsi
movsd 0x1090eb(%rip), %xmm0   # 0x13b020
movsd 0x1090eb(%rip), %xmm2   # 0x13b028
movsd 0x1090eb(%rip), %xmm3   # 0x13b030
movapd %xmm0, %xmm1
callq 0x7a6e4
movl 0x494(%rbx), %r8d
movl 0x498(%rbx), %ecx
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x7b41a
leaq 0x78(%rbx), %r14
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x78e72
leaq 0x78(%rsp), %rsi
movq %r14, %rdi
callq 0x78e18
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x310(%rax)
leaq 0x40(%rsp), %rdi
callq 0xaf380
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x192a55(%rip), %rdi    # 0x1c4a08
callq 0x281a0
testl %eax, %eax
je 0x31ea4
leaq 0x192a29(%rip), %rdi    # 0x1c49f0
movsd 0x109039(%rip), %xmm1   # 0x13b008
xorpd %xmm0, %xmm0
xorps %xmm2, %xmm2
callq 0xc5db6
leaq 0x192a26(%rip), %rdi    # 0x1c4a08
callq 0x275f0
jmp 0x31ea4
leaq 0x192a35(%rip), %rdi    # 0x1c4a28
callq 0x281a0
testl %eax, %eax
je 0x31eb2
leaq 0x192a09(%rip), %rdi    # 0x1c4a10
movsd 0x109029(%rip), %xmm2   # 0x13b038
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
callq 0xc5db6
leaq 0x192a05(%rip), %rdi    # 0x1c4a28
callq 0x275f0
jmp 0x31eb2
movq %rax, %rbx
leaq 0x1929f1(%rip), %rdi    # 0x1c4a28
jmp 0x32043
movq %rax, %rbx
leaq 0x1929c5(%rip), %rdi    # 0x1c4a08
callq 0x275d0
jmp 0x32055
jmp 0x32052
jmp 0x32052
jmp 0x32052
jmp 0x32052
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0xaf380
movq %rbx, %rdi
callq 0x28130
nop