[Bf-blender-cvs] [a169989] master: Freestyle: Fix for iterations over 0D elements in the reversed order.

Tamito Kajiyama noreply at git.blender.org
Sun Feb 2 14:07:24 CET 2014


Commit: a16998911b59956806000826c15a941c53bd33c1
Author: Tamito Kajiyama
Date:   Sun Feb 2 21:59:15 2014 +0900
https://developer.blender.org/rBa16998911b59956806000826c15a941c53bd33c1

Freestyle: Fix for iterations over 0D elements in the reversed order.

The revision is concerned with Interface0DIterator and StrokeVertexIterator.
These iterators can be generated by Interface1D::vertices_end() and
Stroke::stroke_vertices_end(), respectively.  These methods return an
iterator poinitng the next index of the last 0D element (i.e., iterator's is_end
property is true).  When the iterators created in this way are used with
Python's iterator protocol (e.g., in a for-loop), iterations over 0D elements
are automatically performed in the reversed order.  This functionality was
broken after recent revisions concerning Freestyle iterators.

Also made minor code cleanup (white space).

===================================================================

M	source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp
M	source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp
M	source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp
M	source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp

===================================================================

diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp
index 0999688..89a5c36 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp
@@ -113,7 +113,6 @@ static PyObject *AdjacencyIterator_iternext(BPy_AdjacencyIterator *self)
 		PyErr_SetNone(PyExc_StopIteration);
 		return NULL;
 	}
-
 	if (self->at_start)
 		self->at_start = false;
 	else {
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp
index c7c9e34..f85bcdd 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp
@@ -108,15 +108,7 @@ static PyObject *Interface0DIterator_iternext(BPy_Interface0DIterator *self)
 			PyErr_SetNone(PyExc_StopIteration);
 			return NULL;
 		}
-		if (self->at_start)
-			self->at_start = false;
-		else {
-			self->if0D_it->decrement();
-			if (self->if0D_it->isBegin()) {
-				PyErr_SetNone(PyExc_StopIteration);
-				return NULL;
-			}
-		}
+		self->if0D_it->decrement();
 	}
 	else {
 		if (self->if0D_it->isEnd()) {
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp
index f796c8e..3e50510 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp
@@ -96,15 +96,7 @@ static PyObject *StrokeVertexIterator_iternext(BPy_StrokeVertexIterator *self)
 			PyErr_SetNone(PyExc_StopIteration);
 			return NULL;
 		}
-		if (self->at_start)
-			self->at_start = false;
-		else {
-			self->sv_it->increment();
-			if (self->sv_it->isBegin()){
-				PyErr_SetNone(PyExc_StopIteration);
-				return NULL;
-			}
-		}
+		self->sv_it->decrement();
 	}
 	else {
 		if (self->sv_it->isEnd()) {
@@ -119,7 +111,7 @@ static PyObject *StrokeVertexIterator_iternext(BPy_StrokeVertexIterator *self)
 		 * exit the loop if it is. not doing so will result in a crash */
 		else {
 			self->sv_it->increment();
-			if (self->sv_it->isEnd()){
+			if (self->sv_it->isEnd()) {
 				PyErr_SetNone(PyExc_StopIteration);
 				return NULL;
 			}
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp
index ec3e534..e4476cf 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp
@@ -88,15 +88,7 @@ static PyObject *orientedViewEdgeIterator_iternext(BPy_orientedViewEdgeIterator
 			PyErr_SetNone(PyExc_StopIteration);
 			return NULL;
 		}
-		if (self->at_start)
-			self->at_start = false;
-		else {
-			self->ove_it->decrement();
-			if (self->ove_it->isBegin()) {
-				PyErr_SetNone(PyExc_StopIteration);
-				return NULL;
-			}
-		}
+		self->ove_it->decrement();
 	}
 	else {
 		if (self->ove_it->isEnd()) {




More information about the Bf-blender-cvs mailing list