From 15a2287a8efeed84aa09db9e65dde36d4d1f9d0f Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Sun, 7 Jul 2013 15:29:00 +0000 Subject: Fix for incorrect clipping of Freestyle strokes when the viewport preview is used. --- .../intern/python/BPy_ContextFunctions.cpp | 22 ++++++++++++++++++++++ source/blender/freestyle/intern/stroke/Canvas.h | 1 + .../freestyle/intern/stroke/ContextFunctions.cpp | 5 +++++ .../freestyle/intern/stroke/ContextFunctions.h | 7 ++++++- 4 files changed, 34 insertions(+), 1 deletion(-) (limited to 'source/blender/freestyle') diff --git a/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp b/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp index e44dfdf0bae..dd678ee6fbd 100644 --- a/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp +++ b/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp @@ -79,6 +79,26 @@ ContextFunctions_get_canvas_height(PyObject *self) return PyLong_FromLong(ContextFunctions::GetCanvasHeightCF()); } +static char ContextFunctions_get_border___doc__[] = +".. method:: get_border()\n" +"\n" +" Returns the border.\n" +"\n" +" :return: A tuple of 4 numbers (xmin, ymin, xmax, ymax).\n" +" :rtype: tuple\n"; + +static PyObject * +ContextFunctions_get_border(PyObject *self) +{ + BBox border(ContextFunctions::GetBorderCF()); + PyObject *v = PyTuple_New(4); + PyTuple_SET_ITEM(v, 0, PyLong_FromLong(border.getMin().x())); + PyTuple_SET_ITEM(v, 1, PyLong_FromLong(border.getMin().y())); + PyTuple_SET_ITEM(v, 2, PyLong_FromLong(border.getMax().x())); + PyTuple_SET_ITEM(v, 3, PyLong_FromLong(border.getMax().y())); + return v; +} + static char ContextFunctions_load_map___doc__[] = ".. function:: load_map(file_name, map_name, num_levels=4, sigma=1.0)\n" "\n" @@ -232,6 +252,8 @@ static PyMethodDef module_functions[] = { ContextFunctions_get_canvas_width___doc__}, {"get_canvas_height", (PyCFunction)ContextFunctions_get_canvas_height, METH_NOARGS, ContextFunctions_get_canvas_height___doc__}, + {"get_border", (PyCFunction)ContextFunctions_get_border, METH_NOARGS, + ContextFunctions_get_border___doc__}, {"load_map", (PyCFunction)ContextFunctions_load_map, METH_VARARGS | METH_KEYWORDS, ContextFunctions_load_map___doc__}, {"read_map_pixel", (PyCFunction)ContextFunctions_read_map_pixel, METH_VARARGS | METH_KEYWORDS, diff --git a/source/blender/freestyle/intern/stroke/Canvas.h b/source/blender/freestyle/intern/stroke/Canvas.h index 07aa171534a..038b4b3af0f 100644 --- a/source/blender/freestyle/intern/stroke/Canvas.h +++ b/source/blender/freestyle/intern/stroke/Canvas.h @@ -195,6 +195,7 @@ public: virtual int width() const = 0; virtual int height() const = 0; + virtual BBox border() const = 0; virtual BBox scene3DBBox() const = 0; inline const StrokeRenderer *renderer() const diff --git a/source/blender/freestyle/intern/stroke/ContextFunctions.cpp b/source/blender/freestyle/intern/stroke/ContextFunctions.cpp index 42d27a0e5c3..052a6804815 100644 --- a/source/blender/freestyle/intern/stroke/ContextFunctions.cpp +++ b/source/blender/freestyle/intern/stroke/ContextFunctions.cpp @@ -51,6 +51,11 @@ unsigned GetCanvasHeightCF() return Canvas::getInstance()->height(); } +BBox GetBorderCF() +{ + return Canvas::getInstance()->border(); +} + void LoadMapCF(const char *iFileName, const char *iMapName, unsigned iNbLevels, float iSigma) { return Canvas::getInstance()->loadMap(iFileName, iMapName, iNbLevels, iSigma); diff --git a/source/blender/freestyle/intern/stroke/ContextFunctions.h b/source/blender/freestyle/intern/stroke/ContextFunctions.h index 5c0b88fd412..28ce918e919 100644 --- a/source/blender/freestyle/intern/stroke/ContextFunctions.h +++ b/source/blender/freestyle/intern/stroke/ContextFunctions.h @@ -54,10 +54,15 @@ LIB_STROKE_EXPORT unsigned GetCanvasWidthCF(); // GetCanvasHeight -/*! Returns the canvas width */ +/*! Returns the canvas height */ LIB_STROKE_EXPORT unsigned GetCanvasHeightCF(); +// GetBorder +/*! Returns the border */ +LIB_STROKE_EXPORT +BBox GetBorderCF(); + // Load map /*! Loads an image map for further reading */ LIB_STROKE_EXPORT -- cgit v1.2.3