public static bool FindWorldIntersection(Ray worldRay, out LegacyBrushIntersection intersection, bool ignoreInvisibleSurfaces = true, bool ignoreUnrenderables = true, CSGBrush[] ignoreBrushes = null) { var rayStart = worldRay.origin; var rayVector = (worldRay.direction * (Camera.current.farClipPlane - Camera.current.nearClipPlane)); var rayEnd = rayStart + rayVector; return(FindWorldIntersection(rayStart, rayEnd, out intersection, ignoreInvisibleSurfaces, ignoreUnrenderables, ignoreBrushes)); }
public static bool FindWorldIntersection(Vector3 rayStart, Vector3 rayEnd, out LegacyBrushIntersection intersection, bool ignoreInvisibleSurfaces = true, bool ignoreUnrenderables = true, CSGBrush[] ignoreBrushes = null) { intersection = null; if (InternalCSGModelManager.External == null || InternalCSGModelManager.External.RayCastMulti == null) { return(false); } ignoreInvisibleSurfaces = ignoreInvisibleSurfaces && !CSGSettings.ShowCulledSurfaces; var visibleLayers = Tools.visibleLayers; int foundModelCount = 0; if (__foundModels.Length < InternalCSGModelManager.Models.Length) { __foundModels = new CSGModel[InternalCSGModelManager.Models.Length]; } for (var g = 0; g < InternalCSGModelManager.Models.Length; g++) { var model = InternalCSGModelManager.Models[g]; if (!ModelTraits.IsModelSelectable(model)) { continue; } if (ignoreUnrenderables && !ModelTraits.WillModelRender(model) && !Selection.Contains(model.gameObject.GetInstanceID())) { continue; } __foundModels[foundModelCount] = model; foundModelCount++; } if (foundModelCount == 0) { return(false); } LegacyBrushIntersection[] modelIntersections; if (!InternalCSGModelManager.External.RayCastMulti(foundModelCount, __foundModels, rayStart, rayEnd, ignoreInvisibleSurfaces, out modelIntersections, ignoreBrushes: ignoreBrushes)) { return(false); } for (var i = 0; i < modelIntersections.Length; i++) { var modelIntersection = modelIntersections[i]; if (intersection != null && modelIntersection.distance > intersection.distance) { continue; } var brush = modelIntersection.gameObject.GetComponent <CSGBrush>(); if (BrushTraits.IsSurfaceSelectable(brush, modelIntersection.surfaceIndex)) { continue; } modelIntersection.brush = brush; intersection = modelIntersection; } if (intersection == null) { return(false); } return(true); }
public static bool FindWorldIntersection(Vector2 screenPos, out LegacyBrushIntersection intersection, bool ignoreInvisibleSurfaces = true, bool ignoreUnrenderables = true, CSGBrush[] ignoreBrushes = null) { var worldRay = HandleUtility.GUIPointToWorldRay(screenPos); return(FindWorldIntersection(worldRay, out intersection, ignoreInvisibleSurfaces, ignoreUnrenderables, ignoreBrushes)); }
public static bool FindBrushIntersection(CSGBrush brush, Matrix4x4 modelTransformation, Vector3 rayStart, Vector3 rayEnd, out LegacyBrushIntersection intersection) { intersection = null; if (!brush || InternalCSGModelManager.External.RayCastIntoBrush == null) { return(false); } if (!InternalCSGModelManager.External.RayCastIntoBrush(brush.brushNodeID, rayStart, rayEnd, modelTransformation, out intersection, false)) { return(false); } if (BrushTraits.IsSurfaceSelectable(brush, intersection.surfaceIndex)) { return(false); } return(true); }