MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / Init

Method Init

deps/physx/physx/source/physxcooking/src/Adjacencies.cpp:618–693  ·  view source on GitHub ↗

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// * Initializes the component. * \param create [in] the creation structure * \return true if success. */ ////////////////////////////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

616 */
617///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
618bool AdjacenciesBuilder::Init(const ADJACENCIESCREATE& create)
619{
620 // Checkings
621 if(!create.NbFaces) return false;
622
623 // Get some bytes
624 mNbFaces = create.NbFaces;
625 mFaces = PX_NEW(AdjTriangle)[mNbFaces];
626
627 AdjEdge* Edges = PX_NEW_TEMP(AdjEdge)[mNbFaces*3];
628 PxU32 NbEdges=0;
629
630 // Feed me with triangles.....
631 for(PxU32 i=0;i<mNbFaces;i++)
632 {
633 // Get correct vertex references
634 const PxU32 Ref0 = create.DFaces ? create.DFaces[i*3+0] : create.WFaces ? create.WFaces[i*3+0] : 0;
635 const PxU32 Ref1 = create.DFaces ? create.DFaces[i*3+1] : create.WFaces ? create.WFaces[i*3+1] : 1;
636 const PxU32 Ref2 = create.DFaces ? create.DFaces[i*3+2] : create.WFaces ? create.WFaces[i*3+2] : 2;
637
638 // Add a triangle to the database
639 AddTriangle(Ref0, Ref1, Ref2, i, mFaces, NbEdges, Edges);
640 }
641
642 // At this point of the process we have mFaces & Edges filled with input data. That is:
643 // - a list of triangles with 3 NULL links (i.e. PX_INVALID_U32)
644 // - a list of mNbFaces*3 edges, each edge having 2 vertex references and an owner face.
645
646 // Here NbEdges should be equal to mNbFaces*3.
647 PX_ASSERT(NbEdges==mNbFaces*3);
648
649#ifdef MSH_ADJACENCIES_INCLUDE_TOPOLOGY
650 bool Status = CreateDatabase(mFaces, NbEdges, Edges);
651#else
652 bool Status = CreateDatabase(mFaces, NbEdges, Edges, create);
653#endif
654
655 // We don't need the edges anymore
656 PX_DELETE_ARRAY(Edges);
657
658#ifdef MSH_ADJACENCIES_INCLUDE_CONVEX_BITS
659 // Now create convex information. This creates coupling between adjacencies & edge-list but in this case it's actually the goal:
660 // mixing the two structures to save memory.
661 if(Status && create.Verts)
662 {
663 Gu::EDGELISTCREATE ELC;
664 ELC.NbFaces = create.NbFaces;
665 ELC.DFaces = create.DFaces; // That's where I like having a unified way to do things... We
666 ELC.WFaces = create.WFaces; // can just directly copy the same pointers.
667 ELC.FacesToEdges = true;
668 ELC.Verts = create.Verts;
669 ELC.Epsilon = create.Epsilon;
670
671 Gu::EdgeListBuilder EL;
672 if(EL.init(ELC))
673 {
674 for(PxU32 i=0;i<mNbFaces;i++)
675 {

Callers 3

extractHullPolygonsFunction · 0.45
SDL_SensorInitFunction · 0.45
SDL_JoystickInitFunction · 0.45

Calls 3

AddTriangleFunction · 0.85
CreateDatabaseFunction · 0.85
initMethod · 0.45

Tested by

no test coverage detected