gpt-4-0314· OpenAI
WildChat-4.8M (AI2)
Привет помоги с рефакторингом protected virtual void UpdateTransform() {…
- User
Привет помоги с рефакторингом protected virtual void UpdateTransform() { CheckDeviceIndex();
if (playerTransform == null) return; UpdatePosition(); UpdateRotation(); } private void UpdatePosition() { transform.position = playerTransform.TransformPoint(poseAction[inputSource].localPosition); } private void UpdateRotation() { if (isFireExtinguisher && !isFireExtinguisherUse) { SetFireExtinguisherRotation(); return; } if (IsBoxFireExtinguisher) { SetBoxRotation(); } else { SetDefaultRotation(); } } private void SetFireExtinguisherRotation() { transform.localEulerAngles = fireExtinguisherAngles; } private void SetBoxRotation() { var angle = playerTransform.rotation * poseAction[inputSource].localRotation; transform.rotation = Quaternion.Euler(0, angle.eulerAngles.y, 0); } private void SetDefaultRotation() { if (fireExtinguisherCalibration) { localRotationStart = poseAction[inputSource].localRotation; var angle = playerTransform.rotation * poseAction[inputSource].localRotation * Quaternion.Inverse(localRotationStart); var y = playerTransform.rotation * poseAction[inputSource].localRotation; transform.rotation = Quaternion.Euler(angle.eulerAngles.x, y.eulerAngles.y, angle.eulerAngles.z); return; } Quaternion modifier; if (calibrationRotationImplemented) { modifier = poseAction[inputSource].localRotation * Quaternion.Inverse(localRotationStart); } else { modifier = poseAction[inputSource].localRotation; } transform.rotation = playerTransform.rotation * modifier; } - Assistant
protected virtual void UpdateTransform() { CheckDeviceIndex(); if (playerTransform == null) return; UpdatePosition(); UpdateRotation(); } private void UpdatePosition() { transform.position = playerTransform.TransformPoint(poseAction[inputSource].localPosition); } private void UpdateRotation() { if (isFireExtinguisher && !isFireExtinguisherUse) { SetRotation(fireExtinguisherAngles); return; } if (IsBoxFireExtinguisher) { SetRotation(CalculateBoxEulerAngles()); } else { SetRotation(CalculateDefaultEulerAngles()); } } private void SetRotation(Vector3 eulerAngles) { transform.localEulerAngles = eulerAngles; } private Vector3 CalculateBoxEulerAngles() { var angle = playerTransform.rotation * poseAction[inputSource].localRotation; return new Vector3(0, angle.eulerAngles.y, 0); } private Vector3 CalculateDefaultEulerAngles() { if (fireExtinguisherCalibration) { localRotationStart = poseAction[inputSource].localRotation; var angle = playerTransform.rotation * poseAction[inputSource].localRotation * Quaternion.Inverse(localRotationStart); var y = playerTransform.rotation * poseAction[inputSource].localRotation; return new Vector3(angle.eulerAngles.x, y.eulerAngles.y, angle.eulerAngles.z); } Quaternion modifier = calibrationRotationImplemented ? poseAction[inputSource].localRotation * Quaternion.Inverse(localRotationStart) : poseAction[inputSource].localRotation; var rotation = playerTransform.rotation * modifier; return rotation.eulerAngles; }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.