// File: tomfunkhouser[P]gaps/pkgs/R3Utils/R3SurfelViewer.cpp
// Function: gaps::R3SurfelViewer::R3SurfelViewer(gaps::R3SurfelScene*)
R3SurfelViewer::
R3SurfelViewer(R3SurfelScene *scene)
  : scene(NULL),
    resident_nodes(),
    viewer(),
    viewing_extent(FLT_MAX, FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX, -FLT_MAX),
    elevation_range(FLT_MAX, -FLT_MAX),
    viewing_frustum(),
    center_point(0,0,0),
    selected_point(NULL),
    selected_image(NULL),
    image_inset_size(0.2),
    image_plane_depth(2),
    surfel_size(2),
    surfel_visibility(1),
    normal_visibility(0),
    backfacing_visibility(1),
    aerial_visibility(1),
    terrestrial_visibility(1),
    human_labeled_object_visibility(1),
    object_principal_axes_visibility(0),
    object_oriented_bbox_visibility(0),
    object_relationship_visibility(0),
    object_bbox_visibility(0),
    node_bbox_visibility(0),
    block_bbox_visibility(0),
    scan_viewpoint_visibility(0),
    image_viewpoint_visibility(1),
    image_plane_visibility(0),
    image_inset_visibility(1),
    image_points_visibility(0),
    center_point_visibility(0),
    viewing_extent_visibility(1),
    axes_visibility(0),
    label_visibilities(),
    attribute_visibility_flags(0xFFFFFFFF),
    surfel_color_scheme(R3_SURFEL_VIEWER_COLOR_BY_RGB),
    normal_color(0,1,0),
    background_color(0,0,0),
    object_principal_axes_color(0,1,1),
    object_oriented_bbox_color(0.75,0.0,0.75),
    object_bbox_color(0,1,1),
    node_bbox_color(0,0,1),
    block_bbox_color(0,1,0),
    scan_viewpoint_color(0,1,1),
    image_viewpoint_color(0,1,1),
    center_point_color(0,0,0.5),
    shape_draw_flags(0),
    adapt_working_set_automatically(0),
    target_resolution(100),
    last_target_resolution(0),
    focus_radius(0),
    last_focus_radius(0),
    adapt_subsampling_automatically(0),
    subsampling_factor(1),
    subsampling_multiplier_when_mouse_down(1),
    window_height(0),
    window_width(0),
    shift_down(0),
    ctrl_down(0),
    alt_down(0),
    start_timer(),
    frame_timer(),
    frame_time(-1),
    screenshot_name(NULL),
    ground_z_grid(),
    selected_image_color_pixels(),
    previous_color_image(NULL),
    selected_image_texture_id(0),
    previous_texture_image(NULL),
    vbo_position_buffer(0),
    vbo_normal_buffer(0),
    vbo_color_buffer(0),
    vbo_nsurfels(0),
    shader_program(0),
    vertex_shader(0),
    fragment_shader(0)
{
  // Initialize mouse button state
  mouse_button[0] = 0;
  mouse_button[1] = 0;
  mouse_button[2] = 0;

  // Initialize mouse positions
  mouse_position[0] = 0;
  mouse_position[1] = 0;

  // Initialize mouse positions
  mouse_down_position[0] = 0;
  mouse_down_position[1] = 0;

  // Initialize mouse drag distance
  mouse_drag_distance_squared = 0;

  // Initialize timers
  start_timer.Read();
  frame_timer.Read();

  // Set the scene
  if (scene) SetScene(scene);
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x60(%rsp)
movq %rsi, 0x58(%rsp)
movq 0x60(%rsp), %rdi
movq %rdi, 0x38(%rsp)
leaq 0x28b161(%rip), %rax    # 0x2baaf0
movq %rax, (%rdi)
movq $0x0, 0x8(%rdi)
addq $0x10, %rdi
movq %rdi, 0x30(%rsp)
callq 0x5ae40
movq 0x38(%rsp), %rdi
addq $0x78, %rdi
movq %rdi, 0x40(%rsp)
callq 0xcd370
jmp 0x2f9bd
movq 0x38(%rsp), %rdi
addq $0x120, %rdi            # imm = 0x120
movq %rdi, 0x28(%rsp)
movsd 0x211afa(%rip), %xmm2   # 0x2414d0
movsd 0x211afa(%rip), %xmm5   # 0x2414d8
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
movaps %xmm5, %xmm3
movaps %xmm5, %xmm4
callq 0x133f40
jmp 0x2f9f1
movq 0x38(%rsp), %rdi
addq $0x158, %rdi            # imm = 0x158
movsd 0x211acb(%rip), %xmm0   # 0x2414d0
movsd 0x211acb(%rip), %xmm1   # 0x2414d8
callq 0x1a6050
jmp 0x2fa14
movq 0x38(%rsp), %rdi
addq $0x168, %rdi            # imm = 0x168
movq %rdi, 0x20(%rsp)
callq 0x12df10
jmp 0x2fa2c
movq 0x38(%rsp), %rdi
addq $0x2b0, %rdi            # imm = 0x2B0
xorps %xmm2, %xmm2
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0x1622c0
jmp 0x2fa48
movq 0x38(%rsp), %rax
movq $0x0, 0x2c8(%rax)
movq $0x0, 0x2d0(%rax)
movabsq $0x3fc999999999999a, %rcx # imm = 0x3FC999999999999A
movq %rcx, 0x2d8(%rax)
movabsq $0x4000000000000000, %rcx # imm = 0x4000000000000000
movq %rcx, 0x2e0(%rax)
movq %rcx, 0x2e8(%rax)
movl $0x1, 0x2f0(%rax)
movl $0x0, 0x2f4(%rax)
movl $0x1, 0x2f8(%rax)
movl $0x1, 0x2fc(%rax)
movl $0x1, 0x300(%rax)
movl $0x1, 0x304(%rax)
movl $0x0, 0x308(%rax)
movl $0x0, 0x30c(%rax)
movl $0x0, 0x310(%rax)
movl $0x0, 0x314(%rax)
movl $0x0, 0x318(%rax)
movl $0x0, 0x31c(%rax)
movl $0x0, 0x320(%rax)
movl $0x1, 0x324(%rax)
movl $0x0, 0x328(%rax)
movl $0x1, 0x32c(%rax)
movl $0x0, 0x330(%rax)
movl $0x0, 0x334(%rax)
movl $0x1, 0x338(%rax)
movl $0x0, 0x33c(%rax)
movq %rax, %rdi
addq $0x340, %rdi            # imm = 0x340
movq %rdi, 0x18(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x340(%rax)
movq $0x0, 0x350(%rax)
callq 0x3d1a0
movq 0x38(%rsp), %rdi
addq $0x358, %rdi            # imm = 0x358
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x2f310
jmp 0x2fb95
movq 0x38(%rsp), %rdi
movl $0x0, 0x360(%rdi)
addq $0x368, %rdi            # imm = 0x368
movsd 0x21145d(%rip), %xmm1   # 0x241010
xorps %xmm2, %xmm2
movaps %xmm2, %xmm0
callq 0x1a2880
jmp 0x2fbc0
movq 0x38(%rsp), %rdi
addq $0x380, %rdi            # imm = 0x380
xorps %xmm2, %xmm2
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0x1a2880
jmp 0x2fbdc
movq 0x38(%rsp), %rdi
addq $0x398, %rdi            # imm = 0x398
xorps %xmm0, %xmm0
movsd 0x21141d(%rip), %xmm2   # 0x241010
movaps %xmm2, %xmm1
callq 0x1a2880
jmp 0x2fbfd
movq 0x38(%rsp), %rdi
addq $0x3b0, %rdi            # imm = 0x3B0
xorps %xmm1, %xmm1
movsd 0x2118cc(%rip), %xmm2   # 0x2414e0
movaps %xmm2, %xmm0
callq 0x1a2880
jmp 0x2fc1e
movq 0x38(%rsp), %rdi
addq $0x3c8, %rdi            # imm = 0x3C8
xorps %xmm0, %xmm0
movsd 0x2113db(%rip), %xmm2   # 0x241010
movaps %xmm2, %xmm1
callq 0x1a2880
jmp 0x2fc3f
movq 0x38(%rsp), %rdi
addq $0x3e0, %rdi            # imm = 0x3E0
xorps %xmm1, %xmm1
movsd 0x2113ba(%rip), %xmm2   # 0x241010
movaps %xmm1, %xmm0
callq 0x1a2880
jmp 0x2fc60
movq 0x38(%rsp), %rdi
addq $0x3f8, %rdi            # imm = 0x3F8
movsd 0x21139c(%rip), %xmm1   # 0x241010
xorps %xmm2, %xmm2
movaps %xmm2, %xmm0
callq 0x1a2880
jmp 0x2fc81
movq 0x38(%rsp), %rdi
addq $0x410, %rdi            # imm = 0x410
xorps %xmm0, %xmm0
movsd 0x211378(%rip), %xmm2   # 0x241010
movaps %xmm2, %xmm1
callq 0x1a2880
jmp 0x2fca2
movq 0x38(%rsp), %rdi
addq $0x428, %rdi            # imm = 0x428
xorps %xmm0, %xmm0
movsd 0x211357(%rip), %xmm2   # 0x241010
movaps %xmm2, %xmm1
callq 0x1a2880
jmp 0x2fcc3
movq 0x38(%rsp), %rdi
addq $0x440, %rdi            # imm = 0x440
xorps %xmm1, %xmm1
movsd 0x21135e(%rip), %xmm2   # 0x241038
movaps %xmm1, %xmm0
callq 0x1a2880
jmp 0x2fce4
movq 0x38(%rsp), %rdi
addq $0x458, %rdi            # imm = 0x458
xorl %eax, %eax
movl %eax, %esi
callq 0x2f310
jmp 0x2fcfb
movq 0x38(%rsp), %rdi
movl $0x0, 0x460(%rdi)
movabsq $0x4059000000000000, %rax # imm = 0x4059000000000000
movq %rax, 0x468(%rdi)
movq $0x0, 0x470(%rdi)
movq $0x0, 0x478(%rdi)
movq $0x0, 0x480(%rdi)
movl $0x0, 0x488(%rdi)
movl $0x1, 0x48c(%rdi)
movl $0x1, 0x490(%rdi)
movl $0x0, 0x494(%rdi)
movl $0x0, 0x498(%rdi)
movl $0x0, 0x4bc(%rdi)
movl $0x0, 0x4c0(%rdi)
movl $0x0, 0x4c4(%rdi)
addq $0x4c8, %rdi            # imm = 0x4C8
callq 0x1a20c0
jmp 0x2fd9a
movq 0x38(%rsp), %rdi
addq $0x4d8, %rdi            # imm = 0x4D8
callq 0x1a20c0
jmp 0x2fdad
movq 0x38(%rsp), %rdi
movabsq $-0x4010000000000000, %rax # imm = 0xBFF0000000000000
movq %rax, 0x4e8(%rdi)
movq $0x0, 0x4f0(%rdi)
addq $0x4f8, %rdi            # imm = 0x4F8
movq %rdi, 0x10(%rsp)
xorl %edx, %edx
movl %edx, %esi
callq 0x171fb0
jmp 0x2fde5
movq 0x38(%rsp), %rdi
addq $0x5c8, %rdi            # imm = 0x5C8
movq %rdi, 0x8(%rsp)
callq 0x1963b0
jmp 0x2fdfd
movq 0x38(%rsp), %rdi
movq $0x0, 0x5e0(%rdi)
movl $0x0, 0x5e8(%rdi)
movq $0x0, 0x5f0(%rdi)
movl $0x0, 0x5f8(%rdi)
movl $0x0, 0x5fc(%rdi)
movl $0x0, 0x600(%rdi)
movl $0x0, 0x604(%rdi)
movl $0x0, 0x608(%rdi)
movl $0x0, 0x60c(%rdi)
movl $0x0, 0x610(%rdi)
movl $0x0, 0x49c(%rdi)
movl $0x0, 0x4a0(%rdi)
movl $0x0, 0x4a4(%rdi)
movl $0x0, 0x4a8(%rdi)
movl $0x0, 0x4ac(%rdi)
movl $0x0, 0x4b0(%rdi)
movl $0x0, 0x4b4(%rdi)
movl $0x0, 0x4b8(%rdi)
addq $0x4c8, %rdi            # imm = 0x4C8
callq 0x2ef40
jmp 0x2fec6
movq 0x38(%rsp), %rdi
addq $0x4d8, %rdi            # imm = 0x4D8
callq 0x2ef40
jmp 0x2fed9
cmpq $0x0, 0x58(%rsp)
je 0x2ff82
movq 0x38(%rsp), %rdi
movq 0x58(%rsp), %rsi
movq (%rdi), %rax
movq 0x350(%rax), %rax
callq *%rax
jmp 0x2fefd
jmp 0x2ff82
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
jmp 0x2ffb9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
jmp 0x2ffaf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
jmp 0x2ffa5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
jmp 0x2ff9b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
jmp 0x2ff91
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
jmp 0x2ff87
movq 0x8(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
callq 0x196e00
jmp 0x2ff87
addq $0x68, %rsp
retq
movq 0x10(%rsp), %rdi
callq 0x173460
movq 0x18(%rsp), %rdi
callq 0x3d1b0
movq 0x20(%rsp), %rdi
callq 0x3d210
movq 0x28(%rsp), %rdi
callq 0x3d220
movq 0x40(%rsp), %rdi
callq 0xcd500
movq 0x30(%rsp), %rdi
callq 0x5afd0
movq 0x50(%rsp), %rdi
callq 0x292e0
nopl (%rax)