public static bool FindWorldIntersection(Vector3 rayStart, Vector3 rayEnd, out BrushIntersection intersection, float growDistance = 0.0f, bool ignoreInvisible = true, bool ignoreUnrenderables = true, CSGBrush[] ignoreBrushes = null) { BrushIntersection[] intersections; if (!FindMultiWorldIntersection(rayStart, rayEnd, out intersections, growDistance, ignoreInvisible, ignoreUnrenderables, ignoreBrushes) || intersections == null || intersections.Length == 0) { intersection = null; return(false); } var visibleLayers = Tools.visibleLayers; for (int i = 0; i < intersections.Length; i++) { if (((1 << intersections[i].gameObject.layer) & visibleLayers) == 0) { continue; } intersection = intersections[i]; return(true); } intersection = null; return(false); }
public static bool FindWorldIntersection(Ray worldRay, out BrushIntersection intersection, float growDistance = 0.0f, bool ignoreInvisible = true, bool ignoreUnrenderables = true) { var rayStart = worldRay.origin; var rayVector = (worldRay.direction * (Camera.current.farClipPlane - Camera.current.nearClipPlane)); var rayEnd = rayStart + rayVector; return(FindWorldIntersection(rayStart, rayEnd, out intersection, growDistance, ignoreInvisible, ignoreUnrenderables)); }
public static bool FindWorldIntersection(Ray worldRay, out BrushIntersection 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 BrushIntersection intersection, float growDistance = 0.0f, bool ignoreInvisible = true, bool ignoreUnrenderables = true) { BrushIntersection[] intersections; if (!FindMultiWorldIntersection(rayStart, rayEnd, out intersections, growDistance, ignoreInvisible, ignoreUnrenderables) || intersections.Length == 0) { intersection = null; return(false); } intersection = intersections[0]; return(true); }
public static bool FindSurfaceIntersection(CSGBrush brush, Vector3 modelTranslation, Int32 surfaceIndex, Vector3 rayStart, Vector3 rayEnd, out BrushIntersection intersection, float growDistance = 0.0f) { intersection = null; if (!brush || InternalCSGModelManager.External.RayCastIntoBrush == null) { return(false); } var ignoreInvisible = !CSGSettings.ShowInvisibleSurfaces; if (!InternalCSGModelManager.External.RayCastIntoBrushSurface(brush.brushID, surfaceIndex, rayStart - modelTranslation, rayEnd - modelTranslation, ignoreInvisible, growDistance, out intersection)) { return(false); } if (BrushTraits.IsSurfaceSelectable(brush, intersection.surfaceIndex)) { return(false); } intersection.worldIntersection += modelTranslation; intersection.plane.Translate(modelTranslation); return(true); }
public static bool FindSurfaceIntersection(CSGBrush brush, Vector3 modelTranslation, Int32 surfaceIndex, Vector2 screenPos, out BrushIntersection intersection) { var worldRay = HandleUtility.GUIPointToWorldRay(screenPos); var rayStart = worldRay.origin; var rayVector = (worldRay.direction * (Camera.current.farClipPlane - Camera.current.nearClipPlane)); var rayEnd = rayStart + rayVector; return(FindSurfaceIntersection(brush, modelTranslation, surfaceIndex, rayStart, rayEnd, out intersection)); }
public static bool FindWorldIntersection(Vector2 screenPos, out BrushIntersection intersection, float growDistance = 0.0f, bool ignoreInvisible = true, bool ignoreUnrenderables = true) { var worldRay = HandleUtility.GUIPointToWorldRay(screenPos); return(FindWorldIntersection(worldRay, out intersection, growDistance, ignoreInvisible, ignoreUnrenderables)); }
public static bool FindBrushIntersection(CSGBrush brush, Vector3 modelTranslation, Vector3 rayStart, Vector3 rayEnd, out BrushIntersection intersection) { intersection = null; if (!brush || InternalCSGModelManager.External.RayCastIntoBrush == null) { return(false); } if (!InternalCSGModelManager.External.RayCastIntoBrush(brush.brushID, rayStart - modelTranslation, rayEnd - modelTranslation, out intersection, false)) { return(false); } if (BrushTraits.IsSurfaceSelectable(brush, intersection.surfaceIndex)) { return(false); } intersection.worldIntersection += modelTranslation; intersection.plane.Translate(modelTranslation); return(true); }
public static bool FindWorldIntersection(Vector3 rayStart, Vector3 rayEnd, out BrushIntersection 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; List <CSGModel> models = new List <CSGModel>(); for (var g = 0; g < InternalCSGModelManager.Models.Length; g++) { var model = InternalCSGModelManager.Models[g]; if (!model || !model.isActiveAndEnabled || ((1 << model.gameObject.layer) & visibleLayers) == 0) { continue; } if (ignoreUnrenderables && !ModelTraits.WillModelRender(model) && !Selection.Contains(model.gameObject.GetInstanceID())) { continue; } models.Add(model); } BrushIntersection[] modelIntersections; if (!InternalCSGModelManager.External.RayCastMulti(models.ToArray(), 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 BrushIntersection intersection, bool ignoreInvisibleSurfaces = true, bool ignoreUnrenderables = true, CSGBrush[] ignoreBrushes = null) { var worldRay = HandleUtility.GUIPointToWorldRay(screenPos); return(FindWorldIntersection(worldRay, out intersection, ignoreInvisibleSurfaces, ignoreUnrenderables, ignoreBrushes)); }