protected TPrototype FillElement(TPrototype el, int i, bool isnew) { DispTrIn[i].Decompose(out var scale, out Vector4D rotation, out var pos); el.Name = NameIn[i]; el.FadeInTime = FadeInIn[i]; el.FadeOutTime = FadeOutIn[i]; el.Active = ActiveIn[i]; el.Transparent = TransparentIn[i]; if (BehaviorsIn[i].All(chel => chel != null)) { el.Behaviors = BehaviorsIn[i].ToList(); } el.DisplayTransformation.Position = pos.AsSystemVector(); el.DisplayTransformation.Rotation = rotation.AsSystemQuaternion(); el.DisplayTransformation.Scale = scale.AsSystemVector(); el.TransformationFollowTime = TransFollowTimeIn[i]; el.FadeInDelay = FadeInDelIn[i]; el.FadeOutDelay = FadeOutDelIn[i]; el.SubContextOptions = SubContextIn[i]; el.OnlyHitIfParentIsHit = ClipParentHittingIn[i]; var setvals = SetAttValsIn.TryGetSlice(i) || isnew; el.SetAttachedValues = setvals; if (setvals) { if (el.Value == null) { el.Value = new AttachedValues(); } el.Value.Values = AttValsIn[i].ToArray(); el.Value.Texts = AttTextsIn[i].ToArray(); el.Value.Auxiliary.Clear(); for (int j = 0; j < AttAuxKeysIn[i].SliceCount; j++) { if (string.IsNullOrWhiteSpace(AttAuxKeysIn[i].TryGetSlice(j))) { continue; } el.Value.Auxiliary.UpdateGeneric(AttAuxKeysIn[i].TryGetSlice(j), AttAuxIn[i].TryGetSlice(j)); } } var trupdmode = isnew ? ApplyTransformMode.All : TrUpdateModeIn[i].Aggregate(ApplyTransformMode.None, (current, mode) => current | mode); el.TransformApplication = trupdmode; el.Children.Clear(); foreach (var child in ChildrenIn[i].Where(ch => ch != null)) { child.Parent = el; el.Children.Add(child.Id, child); } FillElementAuxData(el, i); el.IsChanged = ElementNodeUtils.ChangedFrames; return(el); }
public override IEnumerable <HtmlTextureTouch> GetTouches(int i, int jj) { for (int j = 0; j < FIds[i].SliceCount; j++) { yield return(new HtmlTextureTouch( FIds[i][j], (float)FPoints.TryGetSlice(i, j).x, (float)FPoints.TryGetSlice(i, j).y, FForce.TryGetSlice(i, j), FRadius.TryGetSlice(i, j), FRotation.TryGetSlice(i, j) )); } }
//called when data for any output pin is requested public void Evaluate(int SpreadMax) { if (RefreshIn.TryGetSlice(0) || RtlOrderIn.IsChanged || DivideByPrimaryDpiScalingIn.IsChanged) { var _screens = Screen.AllScreens; var t = Task.Run(() => { SetThreadDpiAwarenessContext(-3); var monitors = _screens.Select(screen => { var monitor = new Monitor { Screen = screen }; monitor.Handle = MonitorFromPoint( new Point(screen.WorkingArea.Left + 5, screen.WorkingArea.Top + 5), MonitorFlag.MONITOR_DEFAULTTONULL ); GetDpiForMonitor( monitor.Handle, MonitorDpiType.MDT_EFFECTIVE_DPI, out var fdpix, out var fdpiy ); GetDpiForMonitor( monitor.Handle, MonitorDpiType.MDT_RAW_DPI, out var rdpix, out var rdpiy ); monitor.EffectiveDpi = new Vector2D(fdpix, fdpiy); monitor.RawDpi = new Vector2D(rdpix, rdpiy); monitor.ScaleFactor = new Vector2D(fdpix / 96.0, fdpiy / 96.0); monitor.PrimaryRelativeScaleFactor = monitor.ScaleFactor; monitor.Bounds = new Vector4D( screen.Bounds.Left, screen.Bounds.Top, screen.Bounds.Width * monitor.ScaleFactor.x, screen.Bounds.Height * monitor.ScaleFactor.y ); monitor.WorkingArea = new Vector4D( screen.WorkingArea.Left, screen.WorkingArea.Top, screen.WorkingArea.Width, screen.WorkingArea.Height ); return(monitor); }).ToList(); if (RtlOrderIn.TryGetSlice(0)) { uint minleft = (uint)-Math.Min(monitors.Min(mon => mon.Screen.WorkingArea.Left), 0); uint mintop = (uint)-Math.Min(monitors.Min(mon => mon.Screen.WorkingArea.Top), 0); monitors = monitors.OrderBy(mon => { ulong res = ((ulong)(mon.Screen.WorkingArea.Left + minleft) << 32) | (ulong)(mon.Screen.WorkingArea.Top + mintop); return(res); }).ToList(); } if (DivideByPrimaryDpiScalingIn.TryGetSlice(0)) { var primary = monitors.FirstOrDefault(mon => mon.Screen.Primary); if (primary != null) { primary.PrimaryRelativeScaleFactor = new Vector2D(1, 1); var psf = primary.ScaleFactor; foreach (var mon in monitors) { mon.Bounds = new Vector4D( mon.Bounds.x / psf.x, mon.Bounds.y / psf.y, mon.Bounds.z / psf.x, mon.Bounds.w / psf.y ); mon.PrimaryRelativeScaleFactor = mon.ScaleFactor / psf; } } } MonitorOut.AssignFrom(monitors); BoundsOut.AssignFrom(from mon in monitors select mon.Bounds); WorkingAreaOut.AssignFrom(from mon in monitors select mon.WorkingArea); DeviceNameOut.AssignFrom(from mon in monitors select mon.Screen.DeviceName); IsPrimaryOut.AssignFrom(from mon in monitors select mon.Screen.Primary); EffectiveDpiOut.AssignFrom(from mon in monitors select mon.EffectiveDpi); RawDpiOut.AssignFrom(from mon in monitors select mon.RawDpi); ScaleFactorOut.AssignFrom(from mon in monitors select mon.ScaleFactor); PrimaryRelativeScaleFactorOut.AssignFrom(from mon in monitors select mon.PrimaryRelativeScaleFactor); }); t.Wait(); } }
/* Button order in rawinput apparently: * Right, Left, X1, X2, Middle * 2, 0, 3, 4, 1 * 1, 4, 0, 2, 3 */ public void Evaluate(int SpreadMax) { Context.ConsiderNewBefore = ConsiderNewIn.TryGetSlice(0); Context.ConsiderReleasedAfter = ConsiderReleasedIn.TryGetSlice(0); Context.MinimumForce = MinForceIn.TryGetSlice(0); if (ThreadsIn.IsChanged) { Context.ParallelThreads = ThreadsIn.TryGetSlice(0); } var touchcount = AuxTouchesIn.SliceCount; var touches = Enumerable.Empty <(Vector2, int, float)>(); touches = touches.Concat(Enumerable.Range(0, Dx11TouchesIn.SliceCount).Where(i => Dx11TouchesIn[i] != null).Select(i => { var touch = Dx11TouchesIn[i]; var pos = new Vector2(touch.Pos.X, touch.Pos.Y); return(pos, touch.Id, Dx11TouchForceIn[i]); })); if (!IsTouchDefault()) { touches = touches.Concat(Enumerable.Range(0, touchcount).Select(i => (AuxTouchesIn[i].xy.AsSystemVector(), (int)AuxTouchesIn[i].w, (float)AuxTouchesIn[i].z))); } Context.MouseAlwaysPresent = AlwaysPresentIn.TryGetSlice(0); Context.MouseTouchForce = MouseForceIn.TryGetSlice(0); Context.MouseTouchId = MouseIdIn.TryGetSlice(0); if (MouseIn.IsConnected && MouseIn.SliceCount > 0) { if (MouseIn[0] != null) { if (_initMo) { Context.SubmitMouse(MouseIn[0]); _initMo = false; } } else { if (!_initMo) { Context.DetachMouse(); _initMo = true; } } } else { if (!_initMo) { Context.DetachMouse(); _initMo = true; } } Context.SubmitTouches(touches); var dt = Host.FrameTime - _prevFrameTime; if (_prevFrameTime <= 0.00001) { dt = 0; } if (ViewTrIn.IsConnected && ViewTrIn.SliceCount > 0) { Context.View = ViewTrIn[0].AsSystemMatrix4X4(); } else { Context.View = SMatrix.Identity; } if (ProjTrIn.IsConnected && ProjTrIn.SliceCount > 0) { Context.Projection = ProjTrIn[0].AsSystemMatrix4X4(); } else { Context.Projection = SMatrix.Identity; } if (AspTrIn.IsConnected && AspTrIn.SliceCount > 0) { Context.AspectRatio = AspTrIn[0].AsSystemMatrix4X4(); } else { Context.AspectRatio = SMatrix.Identity; } if (ElementsIn.IsChanged) { for (int i = 0; i < ElementsIn.SliceCount; i++) { if (ElementsIn[i] == null) { continue; } if (_prevElements.Contains(ElementsIn[i])) { continue; } ElementsIn[i].IsChanged = ElementNodeUtils.ChangedFrames; } _prevElements.AssignFrom(ElementsIn); _areElementsChanged = 2; } if (_areElementsChanged > 0 || ForceUpdateIn.TryGetSlice(0)) { Context.AddOrUpdateElements(true, ElementsIn.Where(el => el != null).ToArray()); _areElementsChanged--; } Context.Mainloop((float)dt); ContextOut[0] = Context; FlatElementsOut.SliceCount = Context.FlatElements.Count; for (int i = 0; i < Context.FlatElements.Count; i++) { var element = Context.FlatElements[i]; FlatElementsOut[i] = element; switch (element.EnvironmentObject) { case null: element.EnvironmentObject = new VEnvironmentData(element); break; case VEnvironmentData venvdat: if (venvdat.FlattenedEvents != null) { continue; } venvdat.FlattenedEvents = new ElementEventFlattener(Host); venvdat.FlattenedEvents.Subscribe(element); break; } } ElementsOut.AssignFrom(Context.RootElements.Values); TouchesOut.AssignFrom(Context.Touches.Values); _prevFrameTime = Host.FrameTime; }
protected override void UpdateOps(ref T ops, int i, int j) { ops.Script = FScript.TryGetSlice(i, j) ?? ""; ops.Execute = FExec.TryGetSlice(i, j); ops.ExecuteOnLoad = FExecOnLoad.TryGetSlice(i, j); }
public void Evaluate(int SpreadMax) { bool changewochildren = (SpreadUtils.AnyChanged( NameIn, ManIdIn, IdIn, FadeInIn, FadeOutIn, FadeInDelIn, FadeOutDelIn, TransFollowTimeIn, BehaviorsIn, TransparentIn, ActiveIn, DispTrIn, TrUpdateModeIn, ClipParentHittingIn, SubContextIn, SetAttValsIn ) || AttachedChanged() || AuxDataChanged()) && AutoUpdateIn.TryGetSlice(0) || ForceUpdateIn.TryGetSlice(0); bool childrenchanged = AutoUpdateIn.TryGetSlice(0) && ChildrenIn.IsChanged || ForceUpdateIn.TryGetSlice(0); bool changed = childrenchanged || changewochildren || SetAttValsIn.TryGetSlice(0); int sprmax = SpreadUtils.SpreadMax( ChildrenIn, NameIn, BehaviorsIn, DispTrIn, ActiveIn, AttAuxKeysIn, AttTextsIn, AttValsIn, IdIn ); ElementProtOut.Stream.IsChanged = false; for (int i = 0; i < ElementProtOut.SliceCount; i++) { if (ElementProtOut[i] == null) { continue; } ElementProtOut[i].IsChanged--; } if (changed || init < 2) { if (ExternalIn.IsChanged) { ElementProtOut.SliceCount = 0; } ElementProtOut.ResizeAndDismiss(sprmax, i => FillElement(ProvidePrototype(i, null), i, true)); ElementIdOut.SliceCount = ElementProtOut.SliceCount; var gchildrenchanged = false; for (int i = 0; i < ElementProtOut.SliceCount; i++) { var isnew = false; if (ElementProtOut[i] == null) { ElementProtOut[i] = ProvidePrototype(i, ManIdIn[i] ? IdIn[i] : null); isnew = true; } bool lchildrenchanged = false; if (!changewochildren && childrenchanged) { if (ChildrenIn[i].SliceCount > 0) { for (int j = 0; j < ChildrenIn[i].SliceCount; j++) { if (ChildrenIn[i][j] == null) { continue; } if (ChildrenIn[i][j].IsChanged > 0) { lchildrenchanged = gchildrenchanged = true; } if (ElementProtOut[i].Children.ContainsKey(ChildrenIn[i][j].Id)) { continue; } ChildrenIn[i][j].IsChanged = ElementNodeUtils.ChangedFrames; lchildrenchanged = gchildrenchanged = true; } } else { lchildrenchanged = ElementProtOut[i].Children.Count > 0; gchildrenchanged = gchildrenchanged || lchildrenchanged; } } if (changewochildren || lchildrenchanged) { FillElement(ElementProtOut[i], i, isnew || init < 2); } if (!UseExternal(i, out var tprot)) { if (ManIdIn[i]) { ElementProtOut[i].Id = IdIn[i]; } } ElementIdOut[i] = ElementProtOut[i].Id; } //FElementProt.Flush(); if (changewochildren || gchildrenchanged) { ElementProtOut.Stream.IsChanged = true; } } init++; }