private static qb_RaycastResult DoPlacementRaycast(Vector3 castPosition,Vector3 rayDirection) { RaycastHit hit; bool success = false; Physics.Raycast(castPosition + (-0.1f * rayDirection),rayDirection,out hit,float.MaxValue); if(hit.collider != null) { success = true; if(window.paintToLayer == true) { if(hit.collider.gameObject.layer != window.layerIndex) success = false; } if(window.paintToSelection == true) { Transform[] selectedObjects = Selection.transforms; bool contains = ArrayUtility.Contains(selectedObjects,hit.collider.transform); if(!contains) success = false; } } qb_RaycastResult result = new qb_RaycastResult(success,hit); return result; }
private static qb_RaycastResult DoPlacementRaycast(Vector3 castPosition,Vector3 rayDirection, qb_Template curTemplate) { RaycastHit hit = new RaycastHit(); bool success = false; // Physics.Raycast(castPosition + (-0.1f * rayDirection),rayDirection,out hit,float.MaxValue,//curTemplate.layerIndex);//obsolete-prob //if the current template is if(curTemplate.paintToLayer == false) Physics.Raycast(castPosition + (-0.1f * rayDirection),rayDirection,out hit,curTemplate.brushRadius);//float.MaxValue); else if(curTemplate.paintToLayer == true && curTemplate.layerIndex != -1) Physics.Raycast(castPosition + (-0.1f * rayDirection),rayDirection,out hit,curTemplate.brushRadius, curTemplate.layerIndex); if(hit.collider != null) { success = true; if(curTemplate.paintToLayer == true) { //if(hit.collider.gameObject.layer != window.layerIndex) if( (1 << hit.collider.gameObject.layer & curTemplate.layerIndex) == 0) success = false; } if(curTemplate.paintToSelection == true) { Transform[] selectedObjects = Selection.transforms; bool contains = ArrayUtility.Contains(selectedObjects,hit.collider.transform); if(!contains) success = false; } } qb_RaycastResult result = new qb_RaycastResult(success,hit); return result; }