Exemple #1
0
        public static void DrawPolygonCenters(LineMeshManager lineManager, CSGBrush brush)
        {
            // todo: check perf and maybe have to cache this somewhere
            var controlState = new ControlMeshState(brush);

            controlState.UpdatePoints(brush.ControlMesh);

            for (int i = 0; i < controlState.PolygonCenterPoints.Length; i++)
            {
                var normal = brush.compareTransformation.localToWorldMatrix.MultiplyVector(controlState.PolygonCenterPlanes[i].normal);
                var pa     = controlState.PolygonCenterPoints[i] + normal * .002f;
                var move   = 2 * .0254f;

                var t1       = Vector3.Cross(normal, Vector3.forward);
                var t2       = Vector3.Cross(normal, Vector3.up);
                var tangent  = t1.magnitude > t2.magnitude ? t1 : t2;
                var tangent2 = Quaternion.AngleAxis(90, normal) * tangent;

                lineManager.DrawLine(pa - tangent * move, pa + tangent * move, ColorSettings.HelperPolygonCenter);
                lineManager.DrawLine(pa - tangent2 * move, pa + tangent2 * move, ColorSettings.HelperPolygonCenter);
            }
        }