// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDImage.cpp
// Function: gaps::RGBDImage::DrawPoints(int, int) const
void RGBDImage::
DrawPoints(int color_scheme, int skip) const
{
  // Push transformation
  CameraToWorld().Push();

  // Enable lighting and material
  if (color_scheme == RGBD_RENDER_COLOR_SCHEME) {
    glEnable(GL_COLOR_MATERIAL);
    glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
    glEnable(GL_LIGHTING);
  }

  // Draw color
  LoadColor(color_scheme);

  // Set point size
  glPointSize(2);

  // Draw points
  if (color_scheme != RGBD_RENDER_COLOR_SCHEME) {
    RNGrfxBegin(RN_GRFX_POINTS);
    R3Point world_position;
    for (int ix = 0; ix < NPixels(RN_X); ix += skip) {
      for (int iy = 0; iy < NPixels(RN_Y); iy += skip) {
        if (RGBDTransformImageToCamera(R2Point(ix+0.5, iy+0.5), world_position, this)) {
          if (color_scheme == RGBD_PHOTO_COLOR_SCHEME) RNLoadRgb(PixelColor(ix, iy));
          R3LoadPoint(world_position);
        }
      }
    }
    RNGrfxEnd();
  }
  else {
    RNGrfxBegin(RN_GRFX_POINTS);
    R3Point world_position, p1, p2;
    for (int ix = 0; ix < NPixels(RN_X); ix += skip) {
      for (int iy = 0; iy < NPixels(RN_Y); iy += skip) {
        if (!RGBDTransformImageToCamera(R2Point(ix+0.5, iy+0.5), world_position, this)) continue;
        if (!RGBDTransformImageToCamera(R2Point(ix+1, iy), p1, this)) continue;
        if (!RGBDTransformImageToCamera(R2Point(ix, iy+1), p2, this)) continue;
        R3Plane plane(world_position, p1, p2);
        R3LoadNormal(plane.Normal());
        R3LoadPoint(world_position);
      }
    }
    RNGrfxEnd();
  }

  // Reset point size
  glPointSize(1);
  
  // Disable lighting and material
  if (color_scheme == RGBD_RENDER_COLOR_SCHEME) {
    glDisable(GL_COLOR_MATERIAL);
    glDisable(GL_LIGHTING);
  }

  // Pop transformation
  CameraToWorld().Pop();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movl %edx, %r14d
movl %esi, %ebx
movq %rdi, %r15
addq $0x30, %rdi
movq 0x30(%r15), %rax
movq %rdi, 0x18(%rsp)
callq *0xb0(%rax)
cmpl $0x2, %ebx
movl %ebx, 0xc(%rsp)
jne 0x1d668
movl $0xb57, %edi            # imm = 0xB57
callq 0x11550
movl $0x408, %edi            # imm = 0x408
movl $0x1602, %esi           # imm = 0x1602
callq 0x113b0
movl $0xb50, %edi            # imm = 0xB50
callq 0x11550
movq (%r15), %rax
pushq $0x2
popq %rsi
movq %r15, %rdi
callq *0xf0(%rax)
movss 0x8baeb(%rip), %xmm0    # 0xa9020
callq 0x11090
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x11150
leaq 0x58(%rsp), %r12
movq %r12, %rdi
callq 0x45d4a
leaq 0x90(%rsp), %r13
movq %r13, %rdi
callq 0x45d4a
leaq 0x40(%rsp), %rdi
callq 0x45d4a
leaq 0x70(%rsp), %rbp
cmpl 0x28(%r15), %ebx
jge 0x1d71a
cvtsi2sd %ebx, %xmm0
movsd %xmm0, 0x28(%rsp)
addsd 0x8aa8d(%rip), %xmm0    # 0xa8018
movsd %xmm0, 0x38(%rsp)
movq %rbx, 0x20(%rsp)
leal 0x1(%rbx), %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x30(%rsp)
xorl %ebx, %ebx
cmpl 0x2c(%r15), %ebx
jge 0x1d65b
cvtsi2sd %ebx, %xmm1
movsd %xmm1, 0x10(%rsp)
addsd 0x8aa57(%rip), %xmm1    # 0xa8018
movq %rbp, %rdi
movsd 0x38(%rsp), %xmm0
callq 0x66640
movq %rbp, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x15cb3
testl %eax, %eax
je 0x1d653
movq %rbp, %rdi
movsd 0x30(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
callq 0x66640
movq %rbp, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x15cb3
testl %eax, %eax
je 0x1d653
leal 0x1(%rbx), %eax
cvtsi2sd %eax, %xmm1
movq %rbp, %rdi
movsd 0x28(%rsp), %xmm0
callq 0x66640
movq %rbp, %rdi
leaq 0x40(%rsp), %rsi
movq %r15, %rdx
callq 0x15cb3
testl %eax, %eax
je 0x1d653
movq %rbp, %rdi
movq %r12, %rsi
movq %r13, %rdx
leaq 0x40(%rsp), %rcx
callq 0x44b18
movq %rbp, %rdi
callq 0x118e0
movq %r12, %rdi
callq 0x11170
addl %r14d, %ebx
jmp 0x1d5a5
movq 0x20(%rsp), %rbx
addl %r14d, %ebx
jmp 0x1d56f
movq (%r15), %rax
movq %r15, %rdi
movl %ebx, %esi
callq *0xf0(%rax)
movss 0x8b9a2(%rip), %xmm0    # 0xa9020
callq 0x11090
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x11150
leaq 0x70(%rsp), %r12
movq %r12, %rdi
callq 0x45d4a
leaq 0x58(%rsp), %r13
cmpl 0x28(%r15), %ebx
jge 0x1d71a
cvtsi2sd %ebx, %xmm0
addsd 0x8a968(%rip), %xmm0    # 0xa8018
movsd %xmm0, 0x10(%rsp)
xorl %ebp, %ebp
cmpl 0x2c(%r15), %ebp
jge 0x1d715
cvtsi2sd %ebp, %xmm1
addsd 0x8a94e(%rip), %xmm1    # 0xa8018
movq %r13, %rdi
movsd 0x10(%rsp), %xmm0
callq 0x66640
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x15cb3
testl %eax, %eax
je 0x1d710
cmpl $0x1, 0xc(%rsp)
jne 0x1d708
movq %r13, %rdi
movq %r15, %rsi
movl %ebx, %edx
movl %ebp, %ecx
callq 0x1c31e
movq %r13, %rdi
callq 0x1b8bb
movq %r12, %rdi
callq 0x11170
addl %r14d, %ebp
jmp 0x1d6b8
addl %r14d, %ebx
jmp 0x1d69e
callq 0x117d0
movss 0x8b8fd(%rip), %xmm0    # 0xa9024
callq 0x11090
cmpl $0x2, 0xc(%rsp)
jne 0x1d747
movl $0xb57, %edi            # imm = 0xB57
callq 0x111a0
movl $0xb50, %edi            # imm = 0xB50
callq 0x111a0
movq 0x18(%rsp), %rdi
movq (%rdi), %rax
callq *0xb8(%rax)
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop