| 800 | } |
| 801 | |
| 802 | int32 b2ParticleSystem::DestroyParticlesInShape( |
| 803 | const b2Shape& shape, const b2Transform& xf, |
| 804 | bool callDestructionListener) |
| 805 | { |
| 806 | b2Assert(m_world->IsLocked() == false); |
| 807 | if (m_world->IsLocked()) |
| 808 | { |
| 809 | return 0; |
| 810 | } |
| 811 | |
| 812 | class DestroyParticlesInShapeCallback : public b2QueryCallback |
| 813 | { |
| 814 | public: |
| 815 | DestroyParticlesInShapeCallback( |
| 816 | b2ParticleSystem* system, const b2Shape& shape, |
| 817 | const b2Transform& xf, bool callDestructionListener) |
| 818 | { |
| 819 | m_system = system; |
| 820 | m_shape = &shape; |
| 821 | m_xf = xf; |
| 822 | m_callDestructionListener = callDestructionListener; |
| 823 | m_destroyed = 0; |
| 824 | } |
| 825 | |
| 826 | bool ReportFixture(b2Fixture* fixture) |
| 827 | { |
| 828 | B2_NOT_USED(fixture); |
| 829 | return false; |
| 830 | } |
| 831 | |
| 832 | bool ReportParticle(const b2ParticleSystem* particleSystem, int32 index) |
| 833 | { |
| 834 | if (particleSystem != m_system) |
| 835 | return false; |
| 836 | |
| 837 | b2Assert(index >=0 && index < m_system->m_count); |
| 838 | if (m_shape->TestPoint(m_xf, |
| 839 | m_system->m_positionBuffer.data[index])) |
| 840 | { |
| 841 | m_system->DestroyParticle(index, m_callDestructionListener); |
| 842 | m_destroyed++; |
| 843 | } |
| 844 | return true; |
| 845 | } |
| 846 | |
| 847 | int32 Destroyed() { return m_destroyed; } |
| 848 | |
| 849 | private: |
| 850 | b2ParticleSystem* m_system; |
| 851 | const b2Shape* m_shape; |
| 852 | b2Transform m_xf; |
| 853 | bool m_callDestructionListener; |
| 854 | int32 m_destroyed; |
| 855 | } callback(this, shape, xf, callDestructionListener); |
| 856 | b2AABB aabb; |
| 857 | shape.ComputeAABB(&aabb, xf, 0); |
| 858 | m_world->QueryAABB(&callback, aabb); |
| 859 | return callback.Destroyed(); |
nothing calls this directly
no test coverage detected