// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/R3Graphics/R3Viewer.cpp
// Function: gaps::R3Viewer::WalkCamera(double, double, double, double, int, int, int, int, int, int)
void R3Viewer::
WalkCamera(RNScalar pitch_factor, RNScalar yaw_factor, RNScalar roll_factor, RNScalar step_factor, 
    RNBoolean relax_yaw, RNBoolean relax_roll, int x, int y, int dx, int dy)
{
    // Update pitch
    if (RNIsNotZero(pitch_factor)) {
	RotateCameraPitch(pitch_factor, x, y, dx, dy);
    }

    // Update yaw
    if (RNIsNotZero(yaw_factor)) {
	RotateCameraYaw(yaw_factor, x, y, dx, dy);
    }
    else if (relax_yaw && (RNIsNotZero(camera.Yaw()))) {
	if (RNIsZero(camera.Yaw(), 0.005)) RotateCameraYaw(-1.0 * camera.Yaw());
	else RotateCameraYaw(-0.05 * camera.Yaw());
    }
	
    // Update roll
    if (RNIsNotZero(roll_factor)) {
	RotateCameraRoll(roll_factor, x, y, dx, dy);
    }
    else if (relax_roll && (RNIsNotZero(camera.Roll()))) {
	if (camera.Roll() < 0.01) RotateCameraRoll(-1.0 * camera.Roll());
	else RotateCameraRoll(-0.05 * camera.Roll());
    }
	
    // Translate camera in direction of view ALONG HORIZONTAL PLANE
    if (RNIsNotZero(step_factor)) {
	RNLength vx = (RNLength) ((2 * x) - viewport.Width()) / (RNLength) viewport.Width();
	if (vx > 1.0) vx = 1.0;
	else if (vx < -1.0) vx = -1.0;
	step_factor *= 1.0 - vx*vx;
	R3Vector v = camera.Towards();
	v.Project(R3Plane(camera.Origin(), R3default_camera_up_vector));
	TranslateCamera(v * step_factor);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %r9d, %r14d
movl %r8d, %r15d
movl %ecx, %ebp
movl %edx, 0x1c(%rsp)
movl %esi, %r13d
movsd %xmm3, 0x10(%rsp)
movsd %xmm2, (%rsp)
movq %rdi, %rbx
leaq 0xff43c(%rip), %r12     # 0x13e0d8
movsd (%r12), %xmm3
ucomisd %xmm3, %xmm0
ja 0x3ecba
movapd 0x9b890(%rip), %xmm2    # 0xda540
xorpd %xmm3, %xmm2
ucomisd %xmm0, %xmm2
jbe 0x3ecf1
movq (%rbx), %rax
movq %rbx, %rdi
movl %ebp, %esi
movl %r15d, %edx
movl %r14d, %ecx
movl 0xa0(%rsp), %r8d
movsd %xmm1, 0x20(%rsp)
callq *0x20(%rax)
movsd 0x20(%rsp), %xmm1
movsd (%r12), %xmm3
movapd 0x9b853(%rip), %xmm2    # 0xda540
xorpd %xmm3, %xmm2
ucomisd %xmm3, %xmm1
ja 0x3ed68
ucomisd %xmm1, %xmm2
ja 0x3ed68
testl %r13d, %r13d
je 0x3ed97
leaq 0x8(%rbx), %r13
movq %r13, %rdi
callq 0x3fd92
movsd (%r12), %xmm1
ucomisd %xmm1, %xmm0
ja 0x3ed2c
xorpd 0x9b81a(%rip), %xmm1    # 0xda540
ucomisd %xmm0, %xmm1
jbe 0x3ed97
movq %r13, %rdi
callq 0x3fd92
andpd 0x9ceb4(%rip), %xmm0    # 0xdbbf0
movapd %xmm0, 0x20(%rsp)
movq %r13, %rdi
callq 0x3fd92
leaq 0x20(%rbx), %rsi
movsd 0x9ce82(%rip), %xmm1    # 0xdbbd8
ucomisd 0x20(%rsp), %xmm1
jae 0x3ed87
mulsd 0x9ce7a(%rip), %xmm0    # 0xdbbe0
jmp 0x3ed8f
movq (%rbx), %rax
movq %rbx, %rdi
movapd %xmm1, %xmm0
movl %ebp, %esi
movl %r15d, %edx
movl %r14d, %ecx
movl 0xa0(%rsp), %r8d
callq *0x28(%rax)
jmp 0x3ed97
xorpd 0x9b7b1(%rip), %xmm0    # 0xda540
movq %r13, %rdi
callq 0x4042a
movsd (%r12), %xmm1
movsd (%rsp), %xmm0
ucomisd %xmm1, %xmm0
ja 0x3ee19
xorpd 0x9b790(%rip), %xmm1    # 0xda540
ucomisd %xmm0, %xmm1
ja 0x3ee19
cmpl $0x0, 0x1c(%rsp)
je 0x3ee5e
leaq 0x8(%rbx), %r14
movq %r14, %rdi
callq 0x3fdd0
movsd (%r12), %xmm1
ucomisd %xmm1, %xmm0
ja 0x3ede7
xorpd 0x9b75f(%rip), %xmm1    # 0xda540
ucomisd %xmm0, %xmm1
jbe 0x3ee5e
movq %r14, %rdi
callq 0x3fdd0
movsd %xmm0, (%rsp)
movq %r14, %rdi
callq 0x3fdd0
leaq 0x50(%rbx), %rsi
movsd 0x9b220(%rip), %xmm1    # 0xda028
ucomisd (%rsp), %xmm1
jbe 0x3ee34
xorpd 0x9b729(%rip), %xmm0    # 0xda540
jmp 0x3ee3c
movq (%rbx), %rax
movq %rbx, %rdi
movl %ebp, %esi
movl %r15d, %edx
movl %r14d, %ecx
movl 0xa0(%rsp), %r8d
callq *0x30(%rax)
jmp 0x3ee5e
mulsd 0x9cda4(%rip), %xmm0    # 0xdbbe0
movapd %xmm0, (%rsp)
leaq 0x30(%rsp), %r15
movq %r15, %rdi
callq 0x76a98
movq %r14, %rdi
movq %r15, %rsi
movapd (%rsp), %xmm0
callq 0x4042a
movsd (%r12), %xmm0
movsd 0x10(%rsp), %xmm3
ucomisd %xmm0, %xmm3
ja 0x3ee82
xorpd 0x9b6c8(%rip), %xmm0    # 0xda540
ucomisd %xmm3, %xmm0
jbe 0x3ef33
addl %ebp, %ebp
movl 0xa0(%rbx), %eax
subl %eax, %ebp
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
movsd 0x9b172(%rip), %xmm4    # 0xda018
ucomisd %xmm4, %xmm0
movapd %xmm4, %xmm1
ja 0x3eec6
movsd 0x9b618(%rip), %xmm2    # 0xda4d0
ucomisd %xmm0, %xmm2
movapd %xmm0, %xmm1
jbe 0x3eec6
movapd %xmm2, %xmm1
mulsd %xmm1, %xmm1
subsd %xmm1, %xmm4
mulsd %xmm3, %xmm4
movsd %xmm4, 0x10(%rsp)
leaq 0x8(%rbx), %r14
addq $0x50, %rbx
leaq 0x50(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x76a98
leaq 0x103b71(%rip), %rdx    # 0x142a68
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x73f4a
movq %r15, %rdi
movq %rbx, %rsi
callq 0x7692a
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
movsd 0x10(%rsp), %xmm0
callq 0x767fa
movq %r14, %rdi
movq %rbx, %rsi
callq 0x40424
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq