-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix CompactInPlace failure #43
Conversation
mesh/DMesh3.cs
Outdated
if (!vertices_refcount.is_dense) | ||
{ | ||
// find first free vertex, and last used vertex | ||
int iLastV = MaxVertexID - 1, iCurV = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
меня смущает, что iLast устанавливаем как MaxVertexID, но iCurV сравниваем с vertices_refcount.max_index
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тебя зря это смущает, MaxVertexID это
public int MaxVertexID {
get { return vertices_refcount.max_index; }
}
Но ради прозрачности я сменю на vertices_refcount.max_index
явно
mesh/DMesh3.cs
Outdated
|
||
// move cur forward one, last back one, and then search for next valid | ||
iLastV--; iCurV++; | ||
while (vertices_refcount.isValidUnsafe(iLastV) == false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
может сюда добавить проверку на iLast >= 0 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
У меня были эти мысли, но тут непонятно что лучше. С одной стороны, такая проверка почти во всех случаях избыточна, а актуальна только в некоторых кейсах, которые выглядят как что-то нереалистичное
Добавлю их, на всякий случай
Problem
It turned out that
DMesh3.CompactInPlace
works correctly only ifvertices_refcount
,edges_refcount
ortriangles_refcount
buffers have their last value as 0.If it doesn't, the next required value is out of the boundaries of the array, and it fails.
Solution
Add extra boundaries check for all
while
loops working with these buffers.Also, it seems that we can skip iteration over these vectors if we know that they are compact.
Sadly, with whitespace changes VS added spaces in changed expressions.