/// <summary> /// Retrieves a Triangle shape from the resource pool. /// </summary> /// <param name="v1">Position of the first vertex.</param> /// <param name="v2">Position of the second vertex.</param> /// <param name="v3">Position of the third vertex.</param> /// <returns>Initialized TriangleShape.</returns> public static TriangleShape GetTriangle(ref Vector3 v1, ref Vector3 v2, ref Vector3 v3) { TriangleShape toReturn = SubPoolTriangleShape.Take(); toReturn.vA = v1; toReturn.vB = v2; toReturn.vC = v3; return(toReturn); }
/// <summary> /// Retrieves a TriangleCollidable from the resource pool. /// </summary> /// <param name="a">First vertex in the triangle.</param> /// <param name="b">Second vertex in the triangle.</param> /// <param name="c">Third vertex in the triangle.</param> /// <returns>Initialized TriangleCollidable.</returns> public static TriangleCollidable GetTriangleCollidable(ref Vector3 a, ref Vector3 b, ref Vector3 c) { var tri = SubPoolTriangleCollidables.Take(); var shape = tri.Shape; shape.vA = a; shape.vB = b; shape.vC = c; var identity = RigidTransform.Identity; tri.UpdateBoundingBoxForTransform(ref identity); return(tri); }
/// <summary> /// Removes redundant points. Two points are redundant if they occupy the same hash grid cell. /// </summary> /// <param name="points">List of points to prune.</param> /// <param name="cellSize">Size of cells to determine redundancy.</param> public static void RemoveRedundantPoints(RawList <Vector3> points, double cellSize) { var set = BlockedCellSets.Take(); for (int i = points.Count - 1; i >= 0; --i) { var element = points.Elements[i]; var cell = new BlockedCell { X = (int)Math.Floor(element.X / cellSize), Y = (int)Math.Floor(element.Y / cellSize), Z = (int)Math.Floor(element.Z / cellSize) }; if (set.Contains(cell)) { points.FastRemoveAt(i); } else { set.Add(cell); //TODO: Consider adding adjacent cells to guarantee that a point on the border between two cells will still detect the presence //of a point on the opposite side of that border. } } set.Clear(); BlockedCellSets.GiveBack(set); }
private GeneralConvexPairTester GetPair(ref Vector3i position) { // TODO: Efficiency! GeneralConvexPairTester pair = testerPool.Take(); ReusableGenericCollidable <ConvexShape> boxCollidable = new ReusableGenericCollidable <ConvexShape>(mesh.ChunkShape.ShapeAt(position.X, position.Y, position.Z, out Vector3 offs)); pair.Initialize(convex, boxCollidable); boxCollidable.WorldTransform = new RigidTransform(new Vector3( mesh.Position.X + position.X + offs.X, mesh.Position.Y + position.Y + offs.Y, mesh.Position.Z + position.Z + offs.Z)); return(pair); }
private GeneralConvexPairTester GetPair(ref Int3 position) { var pair = testerPool.Take(); var boxCollidable = boxCollidablePool.Take(); boxCollidable.Shape.Width = voxelGrid.Shape.CellWidth; boxCollidable.Shape.Height = voxelGrid.Shape.CellWidth; boxCollidable.Shape.Length = voxelGrid.Shape.CellWidth; pair.Initialize(convex, boxCollidable); boxCollidable.WorldTransform = new RigidTransform(new Vector3( voxelGrid.Position.X + (position.X + 0.5f) * voxelGrid.Shape.CellWidth, voxelGrid.Position.Y + (position.Y + 0.5f) * voxelGrid.Shape.CellWidth, voxelGrid.Position.Z + (position.Z + 0.5f) * voxelGrid.Shape.CellWidth)); return(pair); }
protected override TrianglePairTester GetTester() { return(testerPool.Take()); }
/// <summary> /// Retrieves a Collidable list from the resource pool. /// </summary> /// <returns>Empty Collidable list.</returns> public static RawList <Collidable> GetCollidableList() { return(SubPoolCollidableList.Take()); }
/// <summary> /// Retrieves an BroadPhaseEntry list from the resource pool. /// </summary> /// <returns>Empty BroadPhaseEntry list.</returns> public static RawList <BroadPhaseEntry> GetBroadPhaseEntryList() { return(SubPoolBroadPhaseEntryList.Take()); }
//#endif /// <summary> /// Retrieves a ray cast result list from the resource pool. /// </summary> /// <returns>Empty ray cast result list.</returns> public static RawList <RayCastResult> GetRayCastResultList() { return(SubPoolRayCastResultList.Take()); }
/// <summary> /// Retrieves a simulation island connection from the resource pool. /// </summary> /// <returns>Uninitialized simulation island connection.</returns> public static SimulationIslandConnection GetSimulationIslandConnection() { return(SimulationIslandConnections.Take()); }
/// <summary> /// Retrieves a TriangleCollidable from the resource pool. /// </summary> /// <returns>Initialized TriangleCollidable.</returns> public static TriangleCollidable GetTriangleCollidable() { return(SubPoolTriangleCollidables.Take()); }
/// <summary> /// Retrieves an Entity RawList from the resource pool. /// </summary> /// <returns>Empty Entity raw list.</returns> public static RawList <Entity> GetEntityRawList() { return(SubPoolEntityRawList.Take()); }
/// <summary> /// Retrieves an CompoundChild list from the resource pool. /// </summary> /// <returns>Empty information list.</returns> public static RawList <CompoundChild> GetCompoundChildList() { return(SubPoolCompoundChildList.Take()); }
/// <summary> /// Retrieves a TriangleIndices list from the resource pool. /// </summary> /// <returns>TriangleIndices list.</returns> public static RawList <TriangleMeshConvexContactManifold.TriangleIndices> GetTriangleIndicesList() { return(SubPoolTriangleIndicesList.Take()); }