// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/RGBD/RGBDImage.cpp
// Function: gaps::RGBDImage::WorldBBox() const
R3Box RGBDImage::
WorldBBox(void) const
{
  // Return remembered bounding box of points in world coordinates, if valid
  if (!world_bbox.IsEmpty()) return world_bbox;

  // Compute world bounding box
  R3Box b = R3null_box;
  if (DepthChannel()) {
    // Compute world bounding box of points
    int skip = 1;
    b = R3null_box;
    for (int iy = 0; iy < height; iy += skip) {
      for (int ix = 0; ix < width; ix += skip) {
        R3Point world_position;
        R2Point image_position(ix+0.5, iy+0.5);
        if (RGBDTransformImageToWorld(image_position, world_position, this)) {
          b.Union(world_position);
        }
      }
    }

    // Just so that don't compute again if empty
    if (b.IsEmpty()) b.Union(WorldViewpoint());

    // Remember world bounding box
    ((RGBDImage *) this)->world_bbox = b;
  }
  else {
    // Return conservative bounding box without reading image
    RNLength max_depth = 7.0;
    RNScalar xfocal = Intrinsics()[0][0];
    RNScalar yfocal = Intrinsics()[1][1];
    RNScalar tan_xfov = (xfocal > 0) ? 0.5*NPixels(RN_X) / xfocal : 1.0;
    RNScalar tan_yfov = (yfocal > 0) ? 0.5*NPixels(RN_Y) / yfocal : 1.0;
    R3Point c = WorldViewpoint() + max_depth * WorldTowards();
    R3Vector dx = WorldRight() * max_depth * tan_xfov * WorldRight();
    R3Vector dy = WorldRight() * max_depth * tan_yfov * WorldUp();
    b.Union(WorldViewpoint());
    b.Union(c - dx - dy);
    b.Union(c + dx - dy);
    b.Union(c - dx + dy);
    b.Union(c + dx + dy);
  }

  // Return computed bounding box
  return b;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x188(%rsi), %r15
movq %r15, %rdi
callq 0x155d0
testl %eax, %eax
je 0x1c296
leaq 0xdc3e9(%rip), %rsi     # 0xf8348
movq %rbx, %rdi
callq 0x3e1aa
cmpl $0x4, 0x24(%r14)
jl 0x1c015
movq 0x18(%r14), %rax
cmpq $0x0, 0x18(%rax)
je 0x1c015
movq %r15, 0x18(%rsp)
leaq 0xdc3bb(%rip), %rsi     # 0xf8348
movq %rbx, %rdi
callq 0x1980e
xorl %ebp, %ebp
leaq 0x68(%rsp), %r12
leaq 0x50(%rsp), %r13
cmpl 0x2c(%r14), %ebp
jge 0x1c2a3
cvtsi2sd %ebp, %xmm0
addsd 0x8c061(%rip), %xmm0    # 0xa8018
movsd %xmm0, 0x80(%rsp)
xorl %r15d, %r15d
cmpl 0x28(%r14), %r15d
jge 0x1c011
movq %r12, %rdi
callq 0x45d4a
cvtsi2sd %r15d, %xmm0
addsd 0x8c03a(%rip), %xmm0    # 0xa8018
movq %r13, %rdi
movsd 0x80(%rsp), %xmm1
callq 0x66640
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x15bef
testl %eax, %eax
je 0x1c00c
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3eb10
incl %r15d
jmp 0x1bfc3
incl %ebp
jmp 0x1bfa1
movsd 0x140(%r14), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x160(%r14), %xmm0
movsd %xmm0, 0x90(%rsp)
cvtsi2sdl 0x28(%r14), %xmm0
movapd %xmm0, 0x80(%rsp)
cvtsi2sdl 0x2c(%r14), %xmm0
movapd %xmm0, 0xb0(%rsp)
leaq 0x50(%rsp), %rdi
movq %r14, %rsi
callq 0x155fc
movq %rsp, %rdi
movq %r14, %rsi
callq 0x15686
leaq 0x38(%rsp), %rdi
movq %rsp, %rsi
movsd 0x8cf44(%rip), %xmm0    # 0xa8fc0
callq 0x46c02
leaq 0x68(%rsp), %rdi
leaq 0x50(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq 0x46013
leaq 0x20(%rsp), %rdi
movq %r14, %rsi
callq 0x1fa3c
movq %rsp, %rdi
leaq 0x20(%rsp), %rsi
movsd 0x8cf0e(%rip), %xmm0    # 0xa8fc0
callq 0x46c02
movapd 0x80(%rsp), %xmm1
mulsd 0x8bf50(%rip), %xmm1    # 0xa8018
movsd 0x18(%rsp), %xmm2
divsd %xmm2, %xmm1
xorpd %xmm0, %xmm0
cmpltsd %xmm2, %xmm0
andpd %xmm0, %xmm1
movsd 0x8bf41(%rip), %xmm2    # 0xa8028
andnpd %xmm2, %xmm0
orpd %xmm1, %xmm0
leaq 0x38(%rsp), %rdi
movq %rsp, %rsi
callq 0x46c02
leaq 0x98(%rsp), %rdi
movq %r14, %rsi
callq 0x1fa3c
leaq 0x50(%rsp), %rdi
leaq 0x38(%rsp), %rsi
leaq 0x98(%rsp), %rdx
callq 0x46ed8
leaq 0x98(%rsp), %rdi
movq %r14, %rsi
callq 0x1fa3c
leaq 0x20(%rsp), %rdi
leaq 0x98(%rsp), %rsi
movsd 0x8ce78(%rip), %xmm0    # 0xa8fc0
callq 0x46c02
movapd 0xb0(%rsp), %xmm2
mulsd 0x8beba(%rip), %xmm2    # 0xa8018
movsd 0x90(%rsp), %xmm1
divsd %xmm1, %xmm2
xorpd %xmm0, %xmm0
cmpltsd %xmm1, %xmm0
andpd %xmm0, %xmm2
movsd 0x8bea8(%rip), %xmm1    # 0xa8028
andnpd %xmm1, %xmm0
orpd %xmm2, %xmm0
movq %rsp, %rdi
leaq 0x20(%rsp), %rsi
callq 0x46c02
leaq 0xc0(%rsp), %rdi
movq %r14, %rsi
callq 0x197a6
leaq 0x38(%rsp), %rdi
movq %rsp, %rsi
leaq 0xc0(%rsp), %rdx
callq 0x46ed8
movq %rsp, %rdi
movq %r14, %rsi
callq 0x155fc
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x3eb10
leaq 0x20(%rsp), %rdi
leaq 0x68(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x4649d
movq %rsp, %rdi
leaq 0x20(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq 0x4649d
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x3eb10
leaq 0x20(%rsp), %rdi
leaq 0x68(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x46013
movq %rsp, %rdi
leaq 0x20(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq 0x4649d
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x3eb10
leaq 0x20(%rsp), %rdi
leaq 0x68(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x4649d
movq %rsp, %rdi
leaq 0x20(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq 0x46013
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x3eb10
leaq 0x20(%rsp), %rdi
leaq 0x68(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0x46013
movq %rsp, %rdi
leaq 0x20(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq 0x46013
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x3eb10
jmp 0x1c2d9
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3e1aa
jmp 0x1c2d9
movq %rbx, %rdi
callq 0x155d0
testl %eax, %eax
movq 0x18(%rsp), %r15
je 0x1c2ce
leaq 0x68(%rsp), %rdi
movq %r14, %rsi
callq 0x155fc
leaq 0x68(%rsp), %rsi
movq %rbx, %rdi
callq 0x3eb10
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1980e
movq %rbx, %rax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1c30a
jmp 0x1c30a
jmp 0x1c30a
jmp 0x1c30a
jmp 0x1c30a
jmp 0x1c30a
jmp 0x1c30a
jmp 0x1c30a
jmp 0x1c30a
jmp 0x1c30a
jmp 0x1c30a
jmp 0x1c30a
jmp 0x1c30a
jmp 0x1c30a
movq %rax, %r14
movq %rbx, %rdi
callq 0x3ee72
movq %r14, %rdi
callq 0x11a80
nop