fixed two recently introduced bugs, that cause crashes when removing objects.
one related to UnionFind optimization, the other to broadphase optimizations. Should do better unittesting next time!
This commit is contained in:
@@ -212,7 +212,10 @@ void AxisSweep3::RemoveHandle(unsigned short handle)
|
||||
{
|
||||
Handle* pHandle = GetHandle(handle);
|
||||
|
||||
//RemoveOverlappingPairsContainingProxy(pHandle);
|
||||
//explicitly remove the pairs containing the proxy
|
||||
//we could do it also in the SortMinUp (passing true)
|
||||
//todo: compare performance
|
||||
RemoveOverlappingPairsContainingProxy(pHandle);
|
||||
|
||||
|
||||
// compute current limit of edge arrays
|
||||
|
||||
@@ -26,29 +26,17 @@ UnionFind::~UnionFind()
|
||||
}
|
||||
|
||||
UnionFind::UnionFind()
|
||||
:m_elements(0),
|
||||
m_N(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void UnionFind::Allocate(int N)
|
||||
{
|
||||
if (m_N < N)
|
||||
{
|
||||
//Free(); //not necessary with stl vectors
|
||||
|
||||
m_N = N;
|
||||
m_elements.resize(N);// = new Element[N];
|
||||
}
|
||||
m_elements.resize(N);
|
||||
}
|
||||
void UnionFind::Free()
|
||||
{
|
||||
if (m_N)
|
||||
{
|
||||
m_N=0;
|
||||
m_elements.clear();
|
||||
}
|
||||
m_elements.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +44,7 @@ void UnionFind::reset(int N)
|
||||
{
|
||||
Allocate(N);
|
||||
|
||||
for (int i = 0; i < m_N; i++)
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
m_elements[i].m_id = i; m_elements[i].m_sz = 1;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ class UnionFind
|
||||
{
|
||||
private:
|
||||
std::vector<Element> m_elements;
|
||||
int m_N;
|
||||
|
||||
public:
|
||||
|
||||
@@ -46,7 +45,7 @@ class UnionFind
|
||||
|
||||
inline int getNumElements() const
|
||||
{
|
||||
return m_N;
|
||||
return m_elements.size();
|
||||
}
|
||||
inline bool isRoot(int x) const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user