[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55347] branches/soc-2008-mxcurioni/source /blender/freestyle/intern/stroke/Operators.cpp: Fix for a crash due to a bug in the handling of singularity in stroke creation ,
Tamito Kajiyama
rd6t-kjym at asahi-net.or.jp
Sat Mar 16 23:39:42 CET 2013
Revision: 55347
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55347
Author: kjym3
Date: 2013-03-16 22:39:39 +0000 (Sat, 16 Mar 2013)
Log Message:
-----------
Fix for a crash due to a bug in the handling of singularity in stroke creation,
where additions of a small offset (to prevent vertices from being at the same point)
were not properly done when vertices were shifted in the reverse order.
A problem report by Vicente Carro through personal communications, thanks a lot!
Modified Paths:
--------------
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/Operators.cpp
Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/Operators.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/Operators.cpp 2013-03-16 20:49:46 UTC (rev 55346)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/stroke/Operators.cpp 2013-03-16 22:39:39 UTC (rev 55347)
@@ -1113,8 +1113,9 @@
if (!vprevious.isBegin())
--vprevious;
- // collect a set of overlapping vertices (except the first one)
+ // collect a set of overlapping vertices
std::vector<Interface0D *> overlapping_vertices;
+ overlapping_vertices.push_back(&(*v));
do {
overlapping_vertices.push_back(&(*vnext));
current = next;
@@ -1140,43 +1141,37 @@
delete stroke;
return NULL;
}
+ current = overlapping_vertices.front()->getPoint2D();
Vec2r dir(target - current);
real dist = dir.norm();
real len = 1.0e-3; // default offset length
int nvert = overlapping_vertices.size();
if (dist < len * nvert) {
- len = dist / (nvert + 1);
+ len = dist / nvert;
}
dir.normalize();
Vec2r offset(dir * len);
-#if 0
- if (G.debug & G_DEBUG_FREESTYLE) {
- cout << "#vert " << nvert << " len " << len << " reverse? " << reverse << endl;
- }
-#endif
// add the offset to the overlapping vertices
StrokeVertex *sv;
- std::vector<Interface0D *>::iterator it = overlapping_vertices.begin(),
- itend = overlapping_vertices.end();
+ std::vector<Interface0D *>::iterator it = overlapping_vertices.begin();
if (!reverse) {
- int n = 1;
- for (; it != itend; ++it) {
+ for (int n = 1; n < nvert; n++) {
sv = dynamic_cast<StrokeVertex*>(*it);
sv->setPoint(sv->getPoint() + offset * n);
- ++n;
+ ++it;
}
}
else {
- int n = nvert;
- for (; it != itend; ++it) {
+ int last = nvert - 1;
+ for (int n = 0; n < last; n++) {
sv = dynamic_cast<StrokeVertex*>(*it);
- sv->setPoint(sv->getPoint() + offset * n);
- --n;
+ sv->setPoint(sv->getPoint() + offset * (last - n));
+ ++it;
}
}
if (vnext.isEnd())
- break;
+ break;
}
++v;
++vnext;
More information about the Bf-blender-cvs
mailing list