// File: tomfunkhouser[P]gaps/pkgs/R3Utils/R3SurfelViewer.cpp
// Function: gaps::R3SurfelViewer::DrawNormals() const
void R3SurfelViewer::
DrawNormals(void) const
{
  // Check stuff
  if (!scene) return;
  if (!normal_visibility) return;

  // Draw normals
  glDisable(GL_LIGHTING);
  RNLoadRgb(normal_color);
  RNLength r = 0.00025 * scene->BBox().DiagonalRadius();
  for (int i = 0; i < resident_nodes.NNodes(); i++) {
    R3SurfelNode *node = resident_nodes.Node(i);
    if (!NodeVisibility(node)) continue;
    for (int j = 0; j < node->NBlocks(); j++) {
      R3SurfelBlock *block = node->Block(j);
      const R3Point& block_origin = block->PositionOrigin();
      glPushMatrix();
      glTranslated(block_origin.X(), block_origin.Y(), block_origin.Z());
      RNGrfxBegin(RN_GRFX_LINES);
      for (int k = 0; k < block->NSurfels(); k++) {
        const R3Surfel *surfel = block->Surfel(k);
        double px = surfel->X();
        double py = surfel->Y();
        double pz = surfel->Z();
        double nx = surfel->NX();
        double ny = surfel->NY();
        double nz = surfel->NZ();
        R3LoadPoint(px, py, pz);
        R3LoadPoint(px + r * nx, py + r * ny, pz + r * nz);
      }
      RNGrfxEnd();
      glPopMatrix();
    }
  }
}

// Assembly:
subq $0xa8, %rsp
movq %rdi, 0xa0(%rsp)
movq 0xa0(%rsp), %rax
movq %rax, 0x28(%rsp)
cmpq $0x0, 0x8(%rax)
jne 0x33e18
jmp 0x340f3
movq 0x28(%rsp), %rax
cmpl $0x0, 0x2f4(%rax)
jne 0x33e2b
jmp 0x340f3
movl $0xb50, %edi            # imm = 0xB50
callq 0x28240
movq 0x28(%rsp), %rdi
addq $0x368, %rdi            # imm = 0x368
callq 0x3dfe0
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x3d7d0
movq %rax, %rdi
callq 0x3e0a0
movaps %xmm0, %xmm1
movsd 0x20d701(%rip), %xmm0   # 0x241568
mulsd %xmm1, %xmm0
movsd %xmm0, 0x98(%rsp)
movl $0x0, 0x94(%rsp)
movq 0x28(%rsp), %rdi
movl 0x94(%rsp), %eax
movl %eax, 0x24(%rsp)
addq $0x10, %rdi
callq 0x3df90
movl %eax, %ecx
movl 0x24(%rsp), %eax
cmpl %ecx, %eax
jge 0x340f3
movq 0x28(%rsp), %rdi
addq $0x10, %rdi
movl 0x94(%rsp), %esi
callq 0x3dfb0
movq 0x28(%rsp), %rdi
movq %rax, 0x88(%rsp)
movq 0x88(%rsp), %rsi
callq 0x30370
cmpl $0x0, %eax
jne 0x33edf
jmp 0x340dd
movl $0x0, 0x84(%rsp)
movl 0x84(%rsp), %eax
movl %eax, 0x20(%rsp)
movq 0x88(%rsp), %rdi
callq 0x2f200
movl %eax, %ecx
movl 0x20(%rsp), %eax
cmpl %ecx, %eax
jge 0x340db
movq 0x88(%rsp), %rdi
movl 0x84(%rsp), %esi
callq 0x2f280
movq %rax, 0x78(%rsp)
movq 0x78(%rsp), %rdi
callq 0x3d6b0
movq %rax, 0x70(%rsp)
callq 0x29170
movq 0x70(%rsp), %rdi
callq 0x2ee70
movsd %xmm0, 0x18(%rsp)
movq 0x70(%rsp), %rdi
callq 0x2ee80
movsd %xmm0, 0x10(%rsp)
movq 0x70(%rsp), %rdi
callq 0x2ee90
movsd 0x10(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0x18(%rsp), %xmm0
callq 0x28af0
movl $0x1, %edi
callq 0x3e030
movl $0x0, 0x6c(%rsp)
movl 0x6c(%rsp), %eax
movl %eax, 0xc(%rsp)
movq 0x78(%rsp), %rdi
callq 0x2f2b0
movl %eax, %ecx
movl 0xc(%rsp), %eax
cmpl %ecx, %eax
jge 0x340bb
movq 0x78(%rsp), %rdi
movl 0x6c(%rsp), %esi
callq 0x3e050
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rdi
callq 0x3e0c0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x58(%rsp)
movq 0x60(%rsp), %rdi
callq 0x3e0d0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x50(%rsp)
movq 0x60(%rsp), %rdi
callq 0x3d6c0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x48(%rsp)
movq 0x60(%rsp), %rdi
callq 0x3d650
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x40(%rsp)
movq 0x60(%rsp), %rdi
callq 0x3d670
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x38(%rsp)
movq 0x60(%rsp), %rdi
callq 0x3d690
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0x58(%rsp), %xmm0
movsd 0x50(%rsp), %xmm1
movsd 0x48(%rsp), %xmm2
callq 0x3e0e0
movsd 0x58(%rsp), %xmm1
movsd 0x98(%rsp), %xmm0
movsd 0x40(%rsp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x50(%rsp), %xmm2
movsd 0x98(%rsp), %xmm1
movsd 0x38(%rsp), %xmm3
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
movsd 0x48(%rsp), %xmm3
movsd 0x98(%rsp), %xmm2
movsd 0x30(%rsp), %xmm4
mulsd %xmm4, %xmm2
addsd %xmm3, %xmm2
callq 0x3e0e0
movl 0x6c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x6c(%rsp)
jmp 0x33f8d
callq 0x3e090
callq 0x293f0
movl 0x84(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x84(%rsp)
jmp 0x33eea
jmp 0x340dd
movl 0x94(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x94(%rsp)
jmp 0x33e7f
addq $0xa8, %rsp
retq
nopl (%rax,%rax)