[V2] Any sample for forcefield?
Posted: Sat Nov 28, 2020 12:28 am
is there any sample for forcefield simulation? E.g a forcefield volume will affect any object that inside the volume.
Former forum of queegs; use github discussions now!
https://forum.bepuentertainment.com/
Code: Select all
var broadPhaseEnumerator = new BroadPhaseOverlapEnumerator { Pool = BufferPool, References = new QuickList<CollidableReference>(16, BufferPool) };
Simulation.BroadPhase.GetOverlaps(queryBoundsMin, queryBoundsMax, ref broadPhaseEnumerator);
Code: Select all
struct BroadPhaseOverlapEnumerator : IBreakableForEach<CollidableReference>
{
public QuickList<CollidableReference> References;
//The enumerator never gets stored into unmanaged memory, so it's safe to include a reference type instance.
public BufferPool Pool;
public bool LoopBody(CollidableReference reference)
{
References.Allocate(Pool) = reference;
//If you wanted to do any top-level filtering, this would be a good spot for it.
//The CollidableReference tells you whether it's a body or a static object and the associated handle. You can look up metadata with that.
return true;
}
}