public bool CheckConstraint(Behaviors.ValidateFunctionArguments validateFunctionArguments, CheckConstraintArguments checkConstraintArguments) { if (this.UpstreamConstraint != null) { if (!this.UpstreamConstraint.CheckConstraint(validateFunctionArguments, checkConstraintArguments)) { return(false); } } if (!validateFunctionArguments.ActionsApplied.Contains(Behaviors.ActionsApplied.Translate)) { // Ignore if no translate applied return(true); } Vector3D rotation, scale, translation; Matrix4x4Utils.Decompose(validateFunctionArguments.Transform , out scale , out rotation , out translation); var translation2 = new Vector2D(translation.x, translation.y); var result = translation2.x >= this.Minimum.x && translation2.y >= this.Minimum.y && translation2.x <= this.Maximum.x && translation2.y <= this.Maximum.y; return(result); }
public bool CheckConstraint(Behaviors.ValidateFunctionArguments validateFunctionArguments, CheckConstraintArguments checkConstraintArguments) { if (this.UpstreamConstraint != null) { if (!this.UpstreamConstraint.CheckConstraint(validateFunctionArguments, checkConstraintArguments)) { return(false); } } if (!validateFunctionArguments.ActionsApplied.Contains(Behaviors.ActionsApplied.Rotate)) { // Ignore if no rotation applied return(true); } Vector3D rotation, scale, translation; Matrix4x4Utils.Decompose(validateFunctionArguments.Transform , out scale , out rotation , out translation); return(rotation.z / (Math.PI * 2.0) >= this.Minimum && rotation.z / (Math.PI * 2.0) <= this.Maximum); }
public bool CheckConstraint(Behaviors.ValidateFunctionArguments validateFunctionArguments, CheckConstraintArguments checkConstraintArguments) { if (this.UpstreamConstraint != null) { if (!this.UpstreamConstraint.CheckConstraint(validateFunctionArguments, checkConstraintArguments)) { return(false); } } if (this.HitTestFunction != null) { var localCoordinates = new List <Vector2D>(); var worldCoordinates = new List <Vector2D>(); // Build local coordinates for (int i = 0; i < this.Resolution; i++) { for (int j = 0; j < this.Resolution; j++) { localCoordinates.Add(new Vector2D( ((double)i / (double)(Resolution - 1)) - 0.5, ((double)j / (double)(Resolution - 1)) - 0.5 )); } } // Build world coordinates foreach (var localCoordinate in localCoordinates) { // Ignore local coordinate which doesn't pass slide hit test if (checkConstraintArguments.Slide.DragHitTest(localCoordinate)) { var localCoordinate3 = new Vector3D(localCoordinate); var worldCoordinate3 = validateFunctionArguments.Transform * localCoordinate3; var worldCoordinate = new Vector2D(worldCoordinate3.x, worldCoordinate3.y); worldCoordinates.Add(worldCoordinate); } } // Check if any world coordinates fail hit test foreach (var worldCoordinate in worldCoordinates) { var worldCoordinateInHitTest = worldCoordinate; if (this.HitTestFunction is HitTestImageFileNode.Function) { worldCoordinateInHitTest /= 2.0; } if (!this.HitTestFunction.TestHit(worldCoordinateInHitTest)) // Full screen hit test rather than default quad size { return(false); } } } return(true); }