From f0acdcf13526046236ce561736521100cba58ff1 Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Sun, 30 Oct 2011 16:00:35 +0000 Subject: Fix for stroke rendering instability with stroke geometry shaders. * Stroke::Resample(int nPoints) was not properly working when a wrong value was returned from Stroke::getLength2D(), resulting in repeated warning messages "Warning: incorrect points number" during stroke rendering. The main cause was that stroke geometry shaders did not update the two-dimensional (2D) length (also referred to as curvilinear abscissa) after they modified the 2D points of stroke vertices. Now all stroke geometry shaders make explicit calls for Stroke::UpdateLength() that has been introduced for recomputing the 2D length. Many thanks to Josef who reported the problem together with sample .blend files for reproducing the issue. * Missing Python wrapper of Stroke::getLength2D() was added. --- .../intern/python/Interface1D/BPy_Stroke.cpp | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp') diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp index 7edfde7e8f6..fe215588275 100644 --- a/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp +++ b/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp @@ -223,6 +223,29 @@ static PyObject * Stroke_RemoveVertex( BPy_Stroke *self, PyObject *args ) { Py_RETURN_NONE; } +static char Stroke_UpdateLength___doc__[] = +".. method:: UpdateLength()\n" +"\n" +" Updates the 2D length of the Stroke.\n"; + +static PyObject * Stroke_UpdateLength( BPy_Stroke *self ) { + self->s->UpdateLength(); + + Py_RETURN_NONE; +} + +static char Stroke_getLength2D___doc__[] = +".. method:: getLength2D()\n" +"\n" +" Returns the 2D length of the Stroke.\n" +"\n" +" :return: the 2D length of the Stroke.\n" +" :rtype: float\n"; + +static PyObject * Stroke_getLength2D( BPy_Stroke *self ) { + return PyFloat_FromDouble( self->s->getLength2D() ); +} + static char Stroke_getMediumType___doc__[] = ".. method:: getMediumType()\n" "\n" @@ -415,6 +438,8 @@ static PyMethodDef BPy_Stroke_methods[] = { {"Resample", ( PyCFunction ) Stroke_Resample, METH_VARARGS, Stroke_Resample___doc__}, {"RemoveVertex", ( PyCFunction ) Stroke_RemoveVertex, METH_VARARGS, Stroke_RemoveVertex___doc__}, {"InsertVertex", ( PyCFunction ) Stroke_InsertVertex, METH_VARARGS, Stroke_InsertVertex___doc__}, + {"UpdateLength", ( PyCFunction ) Stroke_UpdateLength, METH_NOARGS, Stroke_UpdateLength___doc__}, + {"getLength2D", ( PyCFunction ) Stroke_getLength2D, METH_NOARGS, Stroke_getLength2D___doc__}, {"getMediumType", ( PyCFunction ) Stroke_getMediumType, METH_NOARGS, Stroke_getMediumType___doc__}, {"getTextureId", ( PyCFunction ) Stroke_getTextureId, METH_NOARGS, Stroke_getTextureId___doc__}, {"hasTips", ( PyCFunction ) Stroke_hasTips, METH_NOARGS, Stroke_hasTips___doc__}, -- cgit v1.2.3