< Summary

Class:BIWGizmosRotate
Assembly:BuilderInWorld
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/Scripts/Gizmos/BIWGizmosRotate.cs
Covered lines:12
Uncovered lines:6
Coverable lines:18
Total lines:48
Line coverage:66.6% (12 of 18)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SetSnapFactor(...)0%110100%
TransformEntity(...)0%330100%
OnBeginDrag(...)0%110100%
RaycastHit(...)0%6200%
GetHitPointToAxisValue(...)0%110100%
SetPreviousAxisValue(...)0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/Scripts/Gizmos/BIWGizmosRotate.cs

#LineLine coverage
 1using System.Collections;
 2using System.Collections.Generic;
 3using DCL.Builder;
 4using UnityEngine;
 5
 6public class BIWGizmosRotate : BIWGizmos
 7{
 8    internal Plane raycastPlane;
 9
 1210    public override void SetSnapFactor(SnapInfo snapInfo) { snapFactor = snapInfo.rotation; }
 11
 12    public override float TransformEntity(Transform entityTransform, IBIWGizmosAxis axis, float axisValue)
 13    {
 114        Space space = worldOrientedGizmos ? Space.World : Space.Self;
 115        Vector3 rotationVector = activeAxis.axisTransform.forward;
 16
 117        float amount = axisValue * Mathf.Rad2Deg;
 118        entityTransform.Rotate(rotationVector, amount, space);
 119        return amount;
 20    }
 21
 22    public override void OnBeginDrag(IBIWGizmosAxis axis, Transform entityTransform)
 23    {
 124        base.OnBeginDrag(axis, entityTransform);
 125        raycastPlane = new Plane(activeAxis.axisTransform.forward, transform.position);
 126    }
 27
 28    public override bool RaycastHit(Ray ray, out Vector3 hitPoint)
 29    {
 030        float raycastHitDistance = 0.0f;
 31
 032        if (raycastPlane.Raycast(ray, out raycastHitDistance))
 33        {
 034            hitPoint = ray.GetPoint(raycastHitDistance);
 035            return true;
 36        }
 037        hitPoint = Vector3.zero;
 038        return false;
 39    }
 40
 41    internal override float GetHitPointToAxisValue(IBIWGizmosAxis axis, Vector3 hitPoint, Vector2 mousePosition)
 42    {
 143        Vector3 hitDir = (hitPoint - transform.position).normalized;
 144        return Vector3.SignedAngle(axis.axisTransform.up, hitDir, axis.axisTransform.forward) * Mathf.Deg2Rad;
 45    }
 46
 247    internal override void SetPreviousAxisValue(float axisValue, float transformValue) { previousAxisValue = axisValue; 
 48}