public HitPlane GenerateGlassHit() { var glassHit = new HitPlane(new Vertex3D(0, 0, -1), _data.GlassHeight); glassHit.SetElasticity(0.2f); return(glassHit); }
private void IndexTableElements() { // index movables _movers = _table.Movables.Select(m => m.GetMover()).ToList(); // index hittables foreach (var hittable in _table.Hittables) { foreach (var hitObject in hittable.GetHitShapes()) { _hitObjects.Add(hitObject); hitObject.CalcHitBBox(); } } // TODO index hit timers // for (var scriptable of this.Table.GetScriptables()) { // this.HitTimers.Push(...Scriptable.GetApi()._getTimers()); // } _hitObjects.AddRange(_table.GetHitShapes()); // these are the table's outer borders _hitPlayfield = _table.GeneratePlayfieldHit(); _hitTopGlass = _table.GenerateGlassHit(); // index flippers _flipperMovers = _table.Flippers.Values.Select(f => f.FlipperMover).ToArray(); }
public HitPlane GenerateGlassHit(IItem item) { var glassHit = new HitPlane(new Vertex3D(0, 0, -1), _table.GlassHeight, item); glassHit.SetElasticity(0.2f); glassHit.ItemIndex = _table.Index; glassHit.ItemVersion = _table.Version; return(glassHit); }
public HitPlane GeneratePlayfieldHit() { var playfieldHit = new HitPlane(new Vertex3D(0, 0, 1), _data.TableHeight); playfieldHit .SetFriction(_data.GetFriction()) .SetElasticity(_data.GetElasticity(), _data.GetElasticityFalloff()) .SetScatter(MathF.DegToRad(_data.GetScatter())); return(playfieldHit); }
public HitPlane GeneratePlayfieldHit(IItem item) { var playfieldHit = new HitPlane(new Vertex3D(0, 0, 1), _table.TableHeight, item); playfieldHit .SetFriction(_data.GetFriction()) .SetElasticity(_data.GetElasticity(), _data.GetElasticityFalloff()) .SetScatter(MathF.DegToRad(_data.GetScatter())); playfieldHit.ItemIndex = _table.Index; playfieldHit.ItemVersion = _table.Version; return(playfieldHit); }
private void UpdatePosition(Vector2 screenPosition) { var ray = context.World.GetRayForLocalBounds(screenPosition); var scene = context.Scene; var intersectionInfo = scene.GetBVHData().GetClosestIntersection(ray); var oldPosition = getPosition(); var newPosition = oldPosition; var world = Object3DControlContext.World; var rayNormal = (oldPosition - world.EyePosition).GetNormal(); if (intersectionInfo == null) { if (HitPlane == null) { HitPlane = new PlaneShape(new Plane(rayNormal, oldPosition), null); } intersectionInfo = HitPlane.GetClosestIntersection(ray); if (intersectionInfo != null) { newPosition = intersectionInfo.HitPosition; } } else { HitPlane = new PlaneShape(new Plane(rayNormal, oldPosition), null); foreach (var object3D in scene.Children) { if (object3D.GetBVHData().Contains(intersectionInfo.HitPosition)) { newPosition = intersectionInfo.HitPosition; break; } } } if (newPosition != oldPosition) { setPosition(newPosition); context.GuiSurface.Invalidate(); } }
public static BlobAssetReference <QuadTreeBlob> CreateBlobAssetReference(HitQuadTree hitQuadTree, HitPlane playfield, HitPlane glass) { using (var builder = new BlobBuilder(Allocator.Temp)) { ref var rootQuadTree = ref builder.ConstructRoot <QuadTreeBlob>(); QuadTree.Create(hitQuadTree, ref rootQuadTree.QuadTree, builder); if (playfield != null) { PlaneCollider.Create(builder, playfield, ref rootQuadTree.PlayfieldCollider); } else { ref var playfieldCollider = ref builder.Allocate(ref rootQuadTree.PlayfieldCollider); playfieldCollider.Header = new ColliderHeader { Type = ColliderType.None }; }
public static void Create(BlobBuilder builder, HitPlane src, ref BlobPtr <Collider> dest) { ref var ptr = ref UnsafeUtility.As <BlobPtr <Collider>, BlobPtr <PlaneCollider> >(ref dest);