public override void OnHit(RaycastHit hit) { if (!this.isActiveAndEnabled || !Physics.Raycast(Cursor.transform.position + Vector3.up * (float)Math3d.vectorPrecission, Vector3.down, maxHeight + (float)Math3d.vectorPrecission, LayerMask.GetMask(new string[] { "Default", "Tree" }))) { return; } UpdateLineDrawing(); if (hit.transform.gameObject.layer == LayerMask.NameToLayer("Point")) { var pid2 = FactManager.AddPointFact(linePositions[1], Vector3.up).Id; FactManager.AddLineFact(hit.transform.gameObject.GetComponent <FactObject>().URI, pid2, true); } else { FactManager.AddPointFact(hit); } }
public override void OnHit(RaycastHit hit) { if (!this.isActiveAndEnabled) { return; } if (hit.transform.gameObject.layer == LayerMask.NameToLayer("Point")) { Fact tempFact = StageStatic.stage.factState[hit.transform.GetComponent <FactObject>().URI]; //we can only reach points that are lower than that with the measuring tape if (/*ActiveToolMode == ToolMode.CreateLineMode && */ tempFact.Representation.transform.position.y > maxHeight) { return; } //If first point was already selected AND second point != first point if (this.TapeModeIsFirstPointSelected && this.TapeModeFirstPointSelected.Id != tempFact.Id) { //Create LineFact FactManager.AddLineFact(this.TapeModeFirstPointSelected.Id, tempFact.Id); this.ResetGadget(); } else { //Activate LineDrawing for preview this.TapeModeIsFirstPointSelected = true; this.TapeModeFirstPointSelected = tempFact; this.ActivateLineDrawing(); } } //if we hit the top snap zone //TODO: check behaviour else if (hit.transform.gameObject.CompareTag("SnapZone")) { if (this.TapeModeIsFirstPointSelected) { RaycastHit downHit; if (Physics.Raycast(hit.transform.gameObject.transform.position - Vector3.down * 2, Vector3.down, out downHit)) { var idA = downHit.transform.gameObject.GetComponent <FactObject>().URI; var idB = this.TapeModeFirstPointSelected.Id; var idC = FactManager.AddPointFact(hit).Id; //Create LineFact FactManager.AddAngleFact(idA, idB, idC, true); this.ResetGadget(); } } } //If no Point was hit else { if (this.TapeModeIsFirstPointSelected) { //Deactivate LineDrawing and first point selection this.ResetGadget(); } //TODO: Hint that only a line can be drawn between already existing points } }