// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Utils/R3SurfelViewer.cpp
// Function: gaps::R3SurfelViewer::NodeVisibility(gaps::R3SurfelNode*) const
int R3SurfelViewer::
NodeVisibility(R3SurfelNode *node) const
{
  // Check node
  if (!node) return 0;

  // Check node complexity
  if (subsampling_factor > 1) {
    if (node->Complexity() < subsampling_factor) return 0;
  }

  // Check if drawing human labeled objects
  if (!human_labeled_object_visibility) {
    R3SurfelObject *object = node->Object(TRUE, TRUE);
    while (object) {
      if (object->HumanLabel()) return 0;
      object = object->Parent();
    }
  }

  // Check if label is visible
  R3SurfelObject *object = node->Object(TRUE, TRUE);
  while (object && object->Parent() && (object->Parent() != scene->RootObject())) object = object->Parent();
  if (object) {
    if (!AttributeVisibility(object->Flags())) return 0;
    R3SurfelLabel *label = object->CurrentLabel();
    if ((label) && !LabelVisibility(label)) return 0;
  }

  // Check elevation range
  if (!elevation_range.IsEmpty()) {
    RNInterval node_range = node->ElevationRange();
    if (!elevation_range.Contains(node_range)) return 0;
  }

  // Check viewing extent
  if (!viewing_extent.IsEmpty()) {
    if (!R3Intersects(viewing_extent, node->BBox())) return 0;
  }
  
#if (R3_SURFEL_VIEWER_DRAW_METHOD != R3_SURFEL_VIEWER_DRAW_WITH_VBO)
  // Check viewing frustum
  if (node->Complexity() > 1000) {
    if (!viewing_frustum.IsEmpty()) {
      if (!R3Intersects(viewing_frustum, node->BBox())) return 0;
    }
  }
#endif
  
  // Passed all tests
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
xorl %ebx, %ebx
testq %rsi, %rsi
je 0x2c267
movq %rsi, %r15
movq %rdi, %r14
cmpl $0x2, 0x48c(%rdi)
jl 0x2c177
movq %r15, %rdi
callq 0x3cfd0
cvtsi2sdl 0x48c(%r14), %xmm1
ucomisd %xmm0, %xmm1
ja 0x2c267
cmpl $0x0, 0x304(%r14)
je 0x2c276
pushq $0x1
popq %rbp
movq %r15, %rdi
movl %ebp, %esi
movl %ebp, %edx
callq 0x3d228
movq 0x8(%r14), %rcx
testq %rax, %rax
je 0x2c1eb
movq %rax, %rdi
movq 0x18(%rax), %rax
testq %rax, %rax
je 0x2c1b2
movq 0x10(%rcx), %rdx
cmpq (%rdx), %rax
jne 0x2c198
movq 0xe8(%rdi), %rax
testq %rax, %rax
movl $0x40000000, %ecx       # imm = 0x40000000
cmovneq %rax, %rcx
testq %rcx, 0x358(%r14)
je 0x2c267
callq 0x43340
testq %rax, %rax
je 0x2c1eb
movq %r14, %rdi
movq %rax, %rsi
callq 0x32914
testl %eax, %eax
je 0x2c267
movsd 0x158(%r14), %xmm0
ucomisd 0x160(%r14), %xmm0
ja 0x2c237
movq %r15, %rdi
callq 0x3d0bc
movq %rsp, %r12
movq %r12, %rdi
movq %rax, %rsi
callq 0xd27d6
movsd (%r12), %xmm0
ucomisd 0x158(%r14), %xmm0
jb 0x2c267
movsd 0x160(%r14), %xmm0
ucomisd 0x8(%rsp), %xmm0
jb 0x2c267
addq $0x120, %r14            # imm = 0x120
movq %r14, %rdi
callq 0x2bb24
testl %eax, %eax
jne 0x2c265
movq %r15, %rdi
callq 0x3d094
xorl %ebx, %ebx
movq %r14, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x7cfd8
testl %eax, %eax
je 0x2c267
movl %ebp, %ebx
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
pushq $0x1
popq %rdx
movq %r15, %rdi
movl %edx, %esi
callq 0x3d228
movq %rax, %r12
testq %r12, %r12
je 0x2c185
movq %r12, %rdi
callq 0x43314
testq %rax, %rax
jne 0x2c267
movq 0x18(%r12), %r12
jmp 0x2c286
nop