// File: tomfunkhouser[P]gaps/pkgs/R3Utils/R3SurfelViewer.cpp
// Function: gaps::R3SurfelViewer::DrawImagePoints() const
void R3SurfelViewer::
DrawImagePoints(void) const
{
  // Get/check stuff
  if (!selected_image) return;
  if (selected_image->ImageWidth() <= 0) return;
  if (selected_image->ImageHeight()<= 0) return;
  if (!image_points_visibility) return;

  // Get depth and color channels
  const R2Grid *depth_channel = selected_image->DepthChannel();
  if (!depth_channel) return;
  if (depth_channel->XResolution() <= 0) return;
  if (depth_channel->YResolution() <= 0) return;
  const R2Image color_channels = selected_image->ColorChannels();
  if (color_channels.Width() <= 0) return;
  if (color_channels.Height() <= 0) return;

  // Draw image points
  glDisable(GL_LIGHTING);
  glPointSize(surfel_size);
  RNGrfxBegin(RN_GRFX_POINTS);
  for (int iy = 0; iy < selected_image->ImageHeight(); iy++) {
    for (int ix = 0; ix < selected_image->ImageWidth(); ix++) {
      RNScalar depth = depth_channel->GridValue(ix, iy);
      if (RNIsZero(depth) || (depth == R2_GRID_UNKNOWN_VALUE)) continue;
      R2Point image_position(ix, iy);
      R3Point world_position = selected_image->TransformFromImageToWorld(image_position);
      RNLoadRgb(color_channels.PixelRGB(ix, iy));
      R3LoadPoint(world_position);
    }
  }
  RNGrfxEnd();
  glPointSize(1);
}

// Assembly:
subq $0xc8, %rsp
movq %rdi, 0xc0(%rsp)
movq 0xc0(%rsp), %rax
movq %rax, 0x38(%rsp)
cmpq $0x0, 0x2d0(%rax)
jne 0x35c2b
jmp 0x35f5b
movq 0x38(%rsp), %rax
movq 0x2d0(%rax), %rdi
callq 0x3e330
cmpl $0x0, %eax
jg 0x35c46
jmp 0x35f5b
movq 0x38(%rsp), %rax
movq 0x2d0(%rax), %rdi
callq 0x3e350
cmpl $0x0, %eax
jg 0x35c61
jmp 0x35f5b
movq 0x38(%rsp), %rax
cmpl $0x0, 0x330(%rax)
jne 0x35c74
jmp 0x35f5b
movq 0x38(%rsp), %rax
movq 0x2d0(%rax), %rdi
callq 0x2f890
movq %rax, 0xb8(%rsp)
cmpq $0x0, 0xb8(%rsp)
jne 0x35c9d
jmp 0x35f5b
movq 0xb8(%rsp), %rdi
callq 0x3dc90
cmpl $0x0, %eax
jg 0x35cb4
jmp 0x35f5b
movq 0xb8(%rsp), %rdi
callq 0x3dcc0
cmpl $0x0, %eax
jg 0x35ccb
jmp 0x35f5b
movq 0x38(%rsp), %rax
movq 0x2d0(%rax), %rsi
leaq 0xa0(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x60920
movq 0x28(%rsp), %rdi
callq 0x3de90
movl %eax, 0x34(%rsp)
jmp 0x35cf9
movl 0x34(%rsp), %eax
cmpl $0x0, %eax
jg 0x35d38
movl $0x1, 0x90(%rsp)
jmp 0x35f4e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x196e00
jmp 0x35f63
leaq 0xa0(%rsp), %rdi
callq 0x3dea0
movl %eax, 0x24(%rsp)
jmp 0x35d4b
movl 0x24(%rsp), %eax
cmpl $0x0, %eax
jg 0x35d64
movl $0x1, 0x90(%rsp)
jmp 0x35f4e
movl $0xb50, %edi            # imm = 0xB50
callq 0x28240
jmp 0x35d70
movq 0x38(%rsp), %rax
movsd 0x2e8(%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
callq 0x280b0
jmp 0x35d88
xorl %edi, %edi
callq 0x3e030
jmp 0x35d91
movl $0x0, 0x8c(%rsp)
movq 0x38(%rsp), %rax
movl 0x8c(%rsp), %ecx
movl %ecx, 0x1c(%rsp)
movq 0x2d0(%rax), %rdi
callq 0x3e350
movl %eax, 0x20(%rsp)
jmp 0x35dbe
movl 0x1c(%rsp), %eax
movl 0x20(%rsp), %ecx
cmpl %ecx, %eax
jge 0x35f2d
movl $0x0, 0x88(%rsp)
movq 0x38(%rsp), %rax
movl 0x88(%rsp), %ecx
movl %ecx, 0x14(%rsp)
movq 0x2d0(%rax), %rdi
callq 0x3e330
movl %eax, 0x18(%rsp)
jmp 0x35dfb
movl 0x14(%rsp), %eax
movl 0x18(%rsp), %ecx
cmpl %ecx, %eax
jge 0x35f15
movq 0xb8(%rsp), %rdi
movl 0x88(%rsp), %esi
movl 0x8c(%rsp), %edx
callq 0x3e5d0
movsd %xmm0, 0x8(%rsp)
jmp 0x35e2e
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x80(%rsp)
movsd 0x80(%rsp), %xmm0
leaq 0x296cfb(%rip), %rax    # 0x2ccb48
movsd (%rax), %xmm1
callq 0x3e610
movl %eax, 0x4(%rsp)
jmp 0x35e5c
movl 0x4(%rsp), %eax
cmpl $0x0, %eax
jne 0x35e7e
movsd 0x80(%rsp), %xmm0
movsd 0x20b6ca(%rip), %xmm1   # 0x241540
ucomisd %xmm1, %xmm0
jne 0x35e80
jp 0x35e80
jmp 0x35eff
cvtsi2sdl 0x88(%rsp), %xmm0
cvtsi2sdl 0x8c(%rsp), %xmm1
leaq 0x70(%rsp), %rdi
callq 0x194a20
jmp 0x35e9e
movq 0x38(%rsp), %rax
movq 0x2d0(%rax), %rsi
leaq 0x58(%rsp), %rdi
leaq 0x70(%rsp), %rdx
movsd 0x20b14c(%rip), %xmm0   # 0x241008
callq 0x630d0
jmp 0x35ec3
movl 0x88(%rsp), %edx
movl 0x8c(%rsp), %ecx
leaq 0x40(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x196e40
jmp 0x35ee5
leaq 0x40(%rsp), %rdi
callq 0x3dfe0
jmp 0x35ef1
leaq 0x58(%rsp), %rdi
callq 0x3e310
jmp 0x35efd
jmp 0x35eff
movl 0x88(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x88(%rsp)
jmp 0x35dd9
jmp 0x35f17
movl 0x8c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8c(%rsp)
jmp 0x35d9c
callq 0x3e090
jmp 0x35f34
movss 0x20baf0(%rip), %xmm0   # 0x241a2c
callq 0x280b0
jmp 0x35f43
movl $0x0, 0x90(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x196e00
addq $0xc8, %rsp
retq
movq 0x98(%rsp), %rdi
callq 0x292e0