| 762 | } |
| 763 | |
| 764 | udword Opcode13Pint::BatchBoxOverlapObjects(PintSQThreadContext context, udword nb, PintOverlapObjectHit* dest, const PintBoxOverlapData* overlaps) |
| 765 | { |
| 766 | AllocSwitch _; |
| 767 | |
| 768 | ASSERT(mSceneTree); |
| 769 | |
| 770 | if(mSceneTree) |
| 771 | { |
| 772 | SQThreadContext* C = (SQThreadContext*)context; |
| 773 | Container& mBoxIndices = C->mBoxIndices; |
| 774 | |
| 775 | SceneOBBCollider SceneRC; |
| 776 | SceneRC.SetFirstContact(false); |
| 777 | SceneRC.SetTemporalCoherence(false); |
| 778 | SceneRC.SetPrimitiveTests(true); |
| 779 | |
| 780 | OBBCollider RC; |
| 781 | RC.SetFirstContact(true); |
| 782 | RC.SetTemporalCoherence(false); |
| 783 | RC.SetPrimitiveTests(true); |
| 784 | RC.SetFullBoxBoxTest(false); |
| 785 | |
| 786 | OBBCache Cache; |
| 787 | Cache.TouchedPrimitives = mBoxIndices; |
| 788 | |
| 789 | Container mBoxIndices2; |
| 790 | udword Entry; |
| 791 | mBoxIndices2.InitSharedBuffers(1, &Entry); |
| 792 | OBBCache Cache2; |
| 793 | Cache2.TouchedPrimitives = mBoxIndices2; |
| 794 | |
| 795 | udword NbHits = 0; |
| 796 | while(nb--) |
| 797 | { |
| 798 | udword Touched=0; |
| 799 | if(SceneRC.Collide(Cache, overlaps->mBox, mSceneTree) && SceneRC.GetContactStatus()) |
| 800 | { |
| 801 | const udword NbMeshes = SceneRC.GetNbTouchedPrimitives(); |
| 802 | for(udword i=0;i<NbMeshes;i++) |
| 803 | { |
| 804 | const udword Index = SceneRC.GetTouchedPrimitives()[i]; |
| 805 | const OpcodeActor* Actor = (const OpcodeActor*)mActors.GetEntries()[Index]; |
| 806 | const OpcodeMesh* Mesh = Actor->mMesh; |
| 807 | |
| 808 | if(RC.Collide(Cache2, overlaps->mBox, Mesh->mModel, null, &Actor->mMeshTM) && RC.GetContactStatus()) |
| 809 | { |
| 810 | Touched++; |
| 811 | } |
| 812 | } |
| 813 | } |
| 814 | |
| 815 | NbHits += Touched; |
| 816 | dest->mNbObjects = Touched; |
| 817 | dest++; |
| 818 | overlaps++; |
| 819 | } |
| 820 | return NbHits; |
| 821 | } |