< Summary

Class:BIWTranslateGizmos
Assembly:BuilderInWorld
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/Scripts/Gizmos/BIWTranslateGizmos.cs
Covered lines:11
Uncovered lines:0
Coverable lines:11
Total lines:36
Line coverage:100% (11 of 11)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SetSnapFactor(...)0%110100%
TransformEntity(...)0%220100%
GetPositionRoundedToSnapFactor(...)0%10100100%

File(s)

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

#LineLine coverage
 1using System.Collections;
 2using System.Collections.Generic;
 3using DCL.Builder;
 4using UnityEngine;
 5
 6public class BIWTranslateGizmos : BIWGizmos
 7{
 8    // Start is called before the first frame update
 1469    public override void SetSnapFactor(SnapInfo snapInfo) { snapFactor = snapInfo.position; }
 10
 11    public override float TransformEntity(Transform entityTransform, IBIWGizmosAxis axis, float axisValue)
 12    {
 113        Vector3 initialEntityPosition = entityTransform.position;
 114        if (snapFactor > 0)
 115            initialEntityPosition = GetPositionRoundedToSnapFactor(entityTransform.position, axisValue);
 16
 117        Vector3 move = activeAxis.axisTransform.forward * axisValue;
 118        Vector3 position = initialEntityPosition + move;
 19
 120        entityTransform.position = position;
 21
 122        return axisValue;
 23    }
 24
 25    private Vector3 GetPositionRoundedToSnapFactor(Vector3 position, float axisValue)
 26    {
 127        Vector3 activeAxisVector = GetActiveAxisVector();
 28
 129        position = new Vector3(
 30            activeAxisVector == Vector3.right ? (axisValue >= 0 ? Mathf.Floor(position.x / snapFactor) : Mathf.Ceil(posi
 31            activeAxisVector == Vector3.up ? (axisValue >= 0 ? Mathf.Floor(position.y / snapFactor) : Mathf.Ceil(positio
 32            activeAxisVector == Vector3.back ? (axisValue >= 0 ? Mathf.Floor(position.z / snapFactor) : Mathf.Ceil(posit
 33
 134        return position;
 35    }
 36}