public static void FastRemoveAt(NonconvexContactManifold *manifold, int index) { --manifold->Count; if (index < manifold->Count) { var contacts = &manifold->Contact0; contacts[index] = contacts[manifold->Count]; } }
unsafe static void AddContact(ref NonconvexReductionChild child, int contactIndexInChild, NonconvexContactManifold *targetManifold) { ref var contact = ref Unsafe.Add(ref child.Manifold.Contact0, contactIndexInChild);
//TODO: Arguably, this could be handled within the streaming batcher. The main advantage of doing so would be CCD-like queries being available. //On the other hand, we may want to simply modularize it. Something like a low level convex batcher, which is used by the more general purpose discrete batcher //(which handles compounds, meshes, and boundary smoothing), which is used by the CCD batcher. unsafe static void ResolveLinearManifold <TMainManifold>(void *mainManifoldPointer, ConvexContactManifold *linearManifold, NonconvexContactManifold *outManifold) { //This function is responsible for prioritizing which contacts to include when there are more contacts than slots. //Note that the linear manifold is constructed from sphere-convex tests whose depths are guaranteed to be less than the deepest contact //of the main manifold by virtue of the contributing spheres being smaller than the containing shape. //Further, while it's possible for the sphere-sourced contacts to be deeper than some of the main manifold contacts due to speculative contact generation, //there is no strong reason to prefer the sphere source contacts just because their depth happens to be greater- in fact, if we trust the main manifold //contact generation logic, they should tend to be more representative of the true manifold. //In other words, we simply trust that all contacts in the main manifold are good choices, and the linear manifold's responsibility is simply to fill in gaps. //If there are no gaps, then we don't use the linear manifold at all. //So first, copy all main manifold contacts. Debug.Assert(linearManifold->Count == 2, "Inner sphere derived contacts should only ever contribute one contact per involved body, no more, no less."); var outContacts = &outManifold->Contact0; if (typeof(TMainManifold) == typeof(ConvexContactManifold)) { var mainManifold = (ConvexContactManifold *)mainManifoldPointer; outManifold->OffsetB = mainManifold->OffsetB; outManifold->Count = mainManifold->Count; var mainManifoldContacts = &mainManifold->Contact0; for (int i = 0; i < outManifold->Count; ++i) { ref var outContact = ref outContacts[i]; ref var mainContact = ref mainManifoldContacts[i]; outContact.Offset = mainContact.Offset; outContact.Depth = mainContact.Depth; outContact.Normal = mainManifold->Normal; outContact.FeatureId = mainContact.FeatureId; }
public unsafe bool ConfigureContactManifold(int workerIndex, CollidablePair pair, NonconvexContactManifold *manifold, out PairMaterialProperties pairMaterial) { GetMaterial(out pairMaterial); return(true); }
internal static void Add(NonconvexContactManifold *manifold, ref Vector3 normal, ref ConvexContact convexContact) { Debug.Assert(manifold->Count < 8); ref var targetContact = ref (&manifold->Contact0)[manifold->Count++];
public unsafe bool ConfigureContactManifold(int workerIndex, CollidablePair pair, NonconvexContactManifold *manifold, out PairMaterialProperties pairMaterial) { pairMaterial = new PairMaterialProperties(); return(false); }
public unsafe void OnPairCompleted(int pairId, NonconvexContactManifold *manifold) { Manifolds.NonconvexManifolds[pairId] = *manifold; Manifolds.ManifoldIsConvex[pairId] = false; }
unsafe void AddContact(NonconvexContactManifold *manifold, ref NonconvexReductionChild sourceChild, ref Vector3 offset, float depth, ref Vector3 normal, int featureId) { ref var target = ref NonconvexContactManifold.Allocate(manifold);
public unsafe bool ConfigureContactManifold(int workerIndex, CollidablePair pair, NonconvexContactManifold *manifold, out PairMaterialProperties pairMaterial) { if (manifold->Count > 0) { Console.WriteLine($"NONCONVEX PAIR: {pair.A} versus {pair.B}"); } ConfigureMaterial(out pairMaterial); return(true); }