Commit Graph

287 Commits

Author SHA1 Message Date
f0acdcf135 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.
2011-10-30 16:00:35 +00:00
f84e8e7640 Fine control of feature edge selection with mesh face and edge marks.
New "face marks" and "edge marks" have been introduced in mesh data
blocks.  In the edit mode of a mesh object, face marks can be put
to selected faces by choosing Mesh >> Faces >> Mark Freestyle Face
from the menu of a 3D View window or Ctrl-F >> Mark Freestyle Face
from the context menu.  Similarly, edge marks can be put to selected
edges by Mesh >> Edges >> Mark Freestyle Edge or Ctrl-E >> Mark
Freestyle Edge.  These marks should work fine with the Subdivision
surface modifier.

Moreover, two new conditions for feature edge selection have been
added to the Parameter Editor mode as described below:

1. The Selection by Edge Types option has now the new Edge Mark type,
which can be used to (de)select feature edges having edge marks.
This option can be used to add to (or remove from) the view map
arbitrary edges of mesh objects.

2. Selection by Face Marks option has been newly introduced, in which
face marks are used for feature edge selection in two ways.  One
option is called "One Face" which is to (de)select feature edges if
one of faces on the left and right of each feature edge has a face
mark.  The other option is "Both Faces" to (de)select feature edges
if both faces on the left and right have a face mark.
2011-10-06 02:04:43 +00:00
6be21a9125 Implemented a calligraphic thickness modifier in the Parameter Editor mode.
Also fixed a typo in the docstring of the CalligraphicShader.
2011-09-11 19:57:38 +00:00
4ec69d5a2b Added an optional argument 'seed' to the Freestyle.Noise class constructor.
The value is used as a seed for random number generation if it is equal to
or greater than zero; otherwise, time is used as a seed.
2011-08-18 23:07:17 +00:00
ce03ec4b86 Merged changes in the trunk up to revision 38543.
Conflicts resolved:
doc/python_api/sphinx_doc_gen.py
source/blender/blenkernel/CMakeLists.txt
source/blender/makesdna/DNA_material_types.h
source/blender/render/intern/source/pipeline.c
source/creator/CMakeLists.txt
2011-07-20 23:33:10 +00:00
33efa9eeb6 Merged changes in the trunk up to revision 35367.
To branch builders: From this revision Python 3.2 will be used.
Don't forget svn update in the "lib" directory as well.
2011-03-06 12:13:32 +00:00
df7f4f639f Two minor fixes:
* Fixed a bug in MaterialF0D::operator() that an error condition was ignored due
to a wrong return value.

* Fixed a typo in the docstring of StrokeVertex::setPoint().
2011-02-22 01:43:08 +00:00
949a752ddd Made stroke rendering stability fixes, with the aim of addressing
occasional unexpected long lines.

1. The Parameter Editor mode was extended to prevent strokes from
doing quick U-turns that "enable" a known bug in strip creation
that generates unexpected long lines in question.

2. A verbose warning message was added to make the existence of
the strip creation bug visible to users.  When the bug affects the
stroke rendering, the following warning shows up in the console:

> Warning: problem in strip creation (the strip is most likely doing a U-turn).

3. The extrapolation option of CurveMapping (used in alpha and
thickness modifiers in the Parameter Editor mode) was identified
as another source of unexpected long lines.  Now the extrapolation
option is unconditionally disabled (even when users enable it
through the GUI).
2011-01-31 20:57:39 +00:00
2d1bc90eed Added Python wrappers for the following Operators static methods:
- getViewEdgeFromIndex()
- getChainFromIndex()
- getStrokeFromIndex()
2010-12-23 09:21:41 +00:00
d8b2d1945a Documentation updates: Added a class hierarchy that shows
inheritance relationships among the classes defined in the
Freestyle module.
2010-08-28 13:52:49 +00:00
f510faed6c Python API documentation updates: a description of class hierarchy
was added to the docstrings of most Python extension types.
2010-08-12 12:17:47 +00:00
a99a466fee * Made the Parameter Editor mode much more functional. Edge selection
criteria, as well as the color/alpha/thickness Along Stroke modifiers
now work.

* Added more curve blend types.  The default is set to "MIX".
2010-07-28 00:43:45 +00:00
1813324544 Added helper functions to the Freestyle module:
* evaluateColorRamp() to evaluate a color ramp at a given point in
the interval 0 to 1.

* evaluateCurveMappingF() to evaluate a curve mapping at a given
point in the interval 0 to 1.
2010-07-26 23:50:32 +00:00
db158b42de Documentation updates: Replaced "string" with "str". 2010-05-28 18:42:11 +00:00
d15f2b562e Fixed the __call__ method of UnaryFunction0DVectorViewShape and
UnaryFunction1DVectorViewShape.  The __call__ method now returns
a list whose elements are either a ViewShape or None.
2010-05-27 21:12:09 +00:00
96e79172a0 Made object names accessible from within style modules.
ViewShape objects in the view map, as well as SShape objects
that can be retrieved with ViewShape::sshape(), now have a
getName() method that returns the name of the object from
which each shape is created.  For instance, visible feature
edges of specific mesh objects (e.g., Cube.001 and Cube.002)
can be selected using custom predicate ObjectNamesUP1D as
follows:

class ObjectNamesUP1D(UnaryPredicate1D):
    def __init__(self, names):
        UnaryPredicate1D.__init__(self)
        self._names = names
    def getName(self):
        return "ObjectNamesUP1D"
    def __call__(self, viewEdge):
        return viewEdge.viewShape().getName() in self._names

upred = AndUP1D(QuantitativeInvisibilityUP1D(0),
                ObjectNamesUP1D(["Cube.001", "Cube.002"]))
Operators.select(upred)
2010-05-23 17:11:44 +00:00
2212564f18 Fixed invalid use of PyUnicode_FromFormat() where PyUnicode_FromString()
should have been used.
2010-05-23 12:10:31 +00:00
02a4dbeff0 Docstring update for Nature::MATERIAL_BOUNDARY (cf. revision 28919). 2010-05-23 00:09:56 +00:00
b85985535d New option for detecting feature edges at material boundaries.
A checkbox "Material Boundaries" has been added to the Freestyle
options in the Layers tab of the Render buttons.  By enabling the
option, any edge between two faces with different materials is
detected as a feature edge.  In style modules, edges at material
boundaries can be tested with pyNatureUP1D(Nature.MATERIAL_BOUNDARY).
2010-05-22 22:21:15 +00:00
f76c3aa376 * Fix for a crash in StrokeVertexIterator::getObject().
* Minor docstring fixes.
2010-05-21 21:27:32 +00:00
bc993fcd55 Minor docstring fixes. 2010-05-14 21:29:13 +00:00
867419b290 Removed partial implementations of the __copy__ method of some Python
extension classes.  Copy constructors should be used to duplicate
objects.
2010-05-09 18:21:36 +00:00
2385c51360 Renamed FrsCurve, FrsNoise and FrsMaterial Python extension types
to those names without the "Frs" prefix.  These types are part of
the Freestyle module, so that there is no need to make their names
globally unique.
2010-05-09 18:05:33 +00:00
dfe2f8dc03 Merged changes in the trunk up to revision 28247. 2010-04-18 02:03:19 +00:00
d7e08f2d33 Major documentation updates. The original Freestyle API reference
(http://freestyle.sourceforge.net/doc/html/index.html) has been
incorporated into the Blender/Freestyle Python API implementation
in the form of Sphinx-based embedded docstrings.  Some C++-specific
descriptions of classes and functions were revised so that they are
suitable for Python programmers.  Missing docstrings were filled,
and sparse descriptions were extended.  By means of the new
documentation system for Blender, an up-to-date Freestyle Python
API reference will be part of the Blender 2.5 documentation.
2010-04-17 23:47:47 +00:00
7a4a3ec626 Removed duplicated definitions of verticesBegin(), verticesEnd(),
pointsBegin(), and pointsEnd().  All these methods are inherited
from the Interface1D class.
2010-04-10 14:46:02 +00:00
67ca348be3 Missing update in the last commit. 2010-04-08 01:42:39 +00:00
d131a8db48 Replaced PyObject_HEAD_INIT(NULL) with PyVarObject_HEAD_INIT(NULL, 0)
in the definitions of Python wrappers.
2010-04-08 01:13:54 +00:00
7ed7524c91 Got rid of a number of compiler warnings with regard to redefinitions
of _POSIX_C_SOURCE and _XOPEN_SOURCE.  There are no functional changes.
Tested with GCC 4.4.1 on Ubuntu 9.10 (karmic).
2010-04-07 23:28:29 +00:00
128f9730f2 Added Freestyle.getCurrentScene() to give access to the current scene
from within style modules.  Calling this function is only valid within
style modules.  Calling it from the Python Interactive Console results
in an error as follows:

>>> import Freestyle
>>> Freestyle.getCurrentScene()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
TypeError: current scene not available
>>>
2009-12-06 22:01:04 +00:00
6d88769cc2 Improved error checks in the Freestyle.Nature class. 2009-10-18 17:57:33 +00:00
211e7be580 Fixed a bug in the Freestyle.Nature class that instances are always
considered True even if their integer values are 0.
2009-10-18 17:28:15 +00:00
94711098e4 * Fixed compiler warnings concerning the lack of a newline at the
end of a file.

* Fixed compiler warnings due to an invalid argument to PyList_New().
NULL was used instead of 0 to create an empty list.
2009-10-15 19:38:45 +00:00
069d21dddf Made the Freestyle Python API compatible with Python 3. 2009-09-27 00:32:20 +00:00
a1d560fc89 Fixed refcount issues in the Python API. 2009-08-08 16:28:10 +00:00
56c76ba21c Added missing #include <typeinfo> to BPy_Convert.h. 2009-08-08 11:18:40 +00:00
ff110c17f7 Fixed argument checking in __init__ methods of Interface1D, Predicates,
Functions, and StrokeShader types.
2009-08-03 15:19:51 +00:00
d4ff63fe20 * Fixed uninitialized pointers in "__init__" methods of UnaryFunction1D types.
There was a known issue for a long time that we occasionally encountered
strange "TypeError: an integer is required" and "RuntimeWarning: tp_compare
didn't return -1 or -2 for exception", as shown in the following unit test
log.  The source of the former error was PyInt_AsLong(obj) being used by
IntegrationType_from_BPy_IntegrationType(obj), where "obj" was not properly
initialized in "__init__" before the converter was called.  The TypeError
was left unattended for a while and showed up when a comparison occurred
and the TypeError was detected, which resulted in the latter warning.

> runTest (__main__.UnaryFunction1DDoubleInitTestCase) ...
> .\blender:211: RuntimeWarning: tp_compare didn't return -1 or -2 for exception
> ERROR
> 
> ======================================================================
> ERROR: runTest (__main__.UnaryFunction1DDoubleInitTestCase)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "init_tests.py", line 211, in runTest
> TypeError: an integer is required
> 
> ----------------------------------------------------------------------

* Also removed unnecessary error messages in "__init__" methods of
UnaryFunction1D types.
2009-08-03 14:38:15 +00:00
e2eb4d567c Fixed the handling of constructor arguments in the following Python
types: Interface0D, SVertex, ViewVertex, StrokeVertex, NonTVertex,
and TVertex.
2009-08-02 22:39:21 +00:00
74027eafcb SWIG/directors dependency removal (cont'd)
Removed all castToSomething() methods from Interface0D's subclasses.
These methods are useless, because introspection-based automatic type
conversion takes place whenever it is applicable.

If you need to rewrite old style modules that rely on the cast methods,
apply the following rewriting rules:

- SVertex.castToSVertex()
- TVertex.castToViewVertex()
- TVertex.castToTVertex()
- NonTVertex.castToViewVertex()
- NonTVertex.castToNonTVertex()

  These 5 methods return an object itself, so just removing a method
  call will suffice.  If you need to handle objects in a different way
  depending on their types, then you can use Python's type checking
  idioms such as "type(obj) is T" and "isinstance(obj, T)".  Example:

    [Original]
    v = it.getObject()
    # try to convert v into a TVertex object
    vertex = v.castToTVertex()
    if vertex != None:
	... # do something on the TVertex object
    # try to convert v into a NonTVertex object
    vertex = v.castToNonTVertex()
    if vertex != None:
	... # do something on the NonTVertex object

    [Rewritten]
    vertex = it.getObject()
    if type(vertex) is TVertex:
	... # do something on the TVertex object
    elif type(vertex) is NonTVertex:
	... # do something on the NonTVertex object

- SVertex.castToViewVertex()
- SVertex.castToTVertex()
- SVertex.castToNonTVertex()

  Use SVertex.viewvertex() instead.  You don't need to care about
  which cast method is appropriate.  SVertex.viewvertex() does, if
  necessary, introspection-based automatic type conversion for you.

- NonTVertex.castToSVertex()

  Use NonTVertex.svertex() instead.

- CurvePoint.castToSVertex()

  Let cp be a CurvePoint object, then this method can be expressed as
  follows:

    if cp.t2d() == 0.0:
	return cp.A() # returns an SVertex
    elif cp.t2d() == 1.0:
	return cp.B() # returns an SVertex
    return None

- CurvePoint.castToViewVertex()
- CurvePoint.castToTVertex()
- CurvePoint.castToNonVertex()

  Similarly, these 3 methods can be expressed as follows:

    if cp.t2d() == 0.0:
	return cp.A().viewvertex()
    elif cp.t2d() == 1.0:
	return cp.B().viewvertex()
    return None
2009-08-02 19:36:18 +00:00
0ea01da4ba Fixed the argument parsing in CurvePoint.__init__(). 2009-08-02 18:25:26 +00:00
cc19c8e270 * Fixed __init__() method so as to corecttly handle arguments.
* Fixed refcount issues in diffuse(), specular(), ambient() and
emission() methods.  Also changed the type of their returned values
from list to tuple.
2009-08-02 17:38:51 +00:00
acf97994bc SWIG/directors dependency removal (cont'd)
* Added to python/BPy_Convert.{cpp,h} 4 utility converters below for
better introspection-based automatic type conversion.

  PyObject * Any_BPy_Interface0D_from_Interface0D( Interface0D& if0D );
  PyObject * Any_BPy_Interface1D_from_Interface1D( Interface1D& if1D );
  PyObject * Any_BPy_FEdge_from_FEdge( FEdge& fe );
  PyObject * Any_BPy_ViewVertex_from_ViewVertex( ViewVertex& vv );

There are 4 corresponding converters without the "Any_" prefix.  All
calls of them in the code base were replaced with these new converters
so that the introspection-based automatic conversion would take place
universally.

* python/BPy_Convert.{cpp,h}: Those C++ to Python converters having
had a "_ptr" suffix were renamed to a name without the suffix, and
their arguments were changed so as to take a reference (e.g.,
ViewVertex&) instead of a pointer (e.g., ViewVertex *).  The changed
converters and their new function prototypes are listed below.  These
converters now return a Python wrapper object that retains the passed
reference, instead of retaining a newly created C++ object by the
converters.

  // Interface0D converters
  PyObject * BPy_Interface0D_from_Interface0D( Interface0D& if0D );
  PyObject * BPy_CurvePoint_from_CurvePoint( CurvePoint& cp );
  PyObject * BPy_StrokeVertex_from_StrokeVertex( StrokeVertex& sv );
  PyObject * BPy_SVertex_from_SVertex( SVertex& sv );
  PyObject * BPy_ViewVertex_from_ViewVertex( ViewVertex& vv );
  PyObject * BPy_TVertex_from_TVertex( TVertex& tv );
  PyObject * BPy_NonTVertex_from_NonTVertex( NonTVertex& ntv );
  // Interface1D converters
  PyObject * BPy_Interface1D_from_Interface1D( Interface1D& if1D );
  PyObject * BPy_Chain_from_Chain( Chain& c );
  PyObject * BPy_FEdge_from_FEdge( FEdge& fe );
  PyObject * BPy_FEdgeSharp_from_FEdgeSharp( FEdgeSharp& fes );
  PyObject * BPy_FEdgeSmooth_from_FEdgeSmooth( FEdgeSmooth& fes );
  PyObject * BPy_Stroke_from_Stroke( Stroke& s );
  PyObject * BPy_ViewEdge_from_ViewEdge( ViewEdge& ve );
  PyObject * BPy_directedViewEdge_from_directedViewEdge( ViewVertex::directedViewEdge& dve );
  // some other converters
  PyObject * BPy_ViewShape_from_ViewShape( ViewShape& vs );
  PyObject * BPy_SShape_from_SShape( SShape& ss );
  PyObject * BPy_FrsMaterial_from_FrsMaterial( FrsMaterial& m );
  PyObject * BPy_StrokeAttribute_from_StrokeAttribute( StrokeAttribute& sa );

* Added a "borrowed" flag to the definitions of Python types being
used to wrap C++ components of Freestyle's internal data structures.
The flag indicates whether or not a Python wrapper object has a
reference to a C++ object that comprises the internal data structures.
The deallocation routines of the Python types check this flag and
release a wrapped C++ object only when it is not part of the internal
data structures.  The following files were modified:

  python/BPy_FrsMaterial.{cpp,h}
  python/BPy_Interface0D.{cpp,h}
  python/BPy_Interface1D.{cpp,h}
  python/BPy_SShape.{cpp,h}
  python/BPy_StrokeAttribute.{cpp,h}
  python/BPy_ViewShape.{cpp,h}
  python/Interface0D/BPy_CurvePoint.cpp
  python/Interface0D/BPy_SVertex.cpp
  python/Interface0D/BPy_ViewVertex.cpp
  python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp
  python/Interface0D/ViewVertex/BPy_NonTVertex.cpp
  python/Interface0D/ViewVertex/BPy_TVertex.cpp
  python/Interface1D/BPy_FEdge.cpp
  python/Interface1D/BPy_FrsCurve.cpp
  python/Interface1D/BPy_Stroke.cpp
  python/Interface1D/BPy_ViewEdge.cpp
  python/Interface1D/Curve/BPy_Chain.cpp
  python/Interface1D/FEdge/BPy_FEdgeSharp.cpp
  python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp

* view_map/Interface[01]D.h, python/BPy_Interface[01]D.cpp: Removed
from the Interface0D and Interface1D C++ classes a back pointer to a
Python wrapper object and all "director" calls.  These classes (and
their subclasses) are used to build Freestyle's main data structures
(such as a view map and strokes) and their class hierarchy is static.
Python wrappers of these C++ classes are only used to access the data
structures from the Python layer, and not intended to extend the data
structures by subclassing the Python wrappers.  Without the necessity
of subclassing in the Python layer, the back pointer to a wrapping
Python object and "director" calls would be useless (actually they
were not used at all), so they were all removed.

* python/Director.{cpp,h}: Removed the definitions of directors that
were no longer used.

* stroke/Stroke.{cpp,h}: Removed an (unused) back pointer to a Python
wrapper object.

* python/BPy_ViewMap.cpp: Fixed a possible null pointer reference.

* python/Interface1D/BPy_FEdge.cpp: Fixed parameter checking in
FEdge___init__().
2009-08-02 16:23:18 +00:00
6d1ad351f3 Changed the type of returned value of BPy_directedViewEdge_from_directedViewEdge()
from list to tuple.
2009-08-01 18:03:43 +00:00
2c829e9bd3 Disabled the Python wrapper of ViewVertex::edgesEnd(), since the
method returns a non-functional orientedViewEdgeIterator instance.
The iteration from the end to the beginning of the sequence relies
on orientedViewEdgeIterator::decrement() which is not actually
implemented in the C++ class.  As a quick fix, the edgesEnd method
now raises a NotImplementedError.
2009-07-31 23:49:12 +00:00
631df8cc01 Added boundary checking to Iterator::increment() and Iterator::decrement()
to avoid an immediate crash.  Now these methods raise a RuntimeError when
the iteration is already at the end.
2009-07-31 23:16:38 +00:00
ba9943e4a7 * Implemented Python's iterator protocol in Interface0DIterator and
orientedViewEdgeIterator.

* Simplified Python-related error handling in C++ class definitions.
The definitions of the following C++ methods were simplified and most
code segments using the C/Python API were moved to Director.cpp.

  ChainingIterator::init()
  ChainingIterator::traverse()
  UnaryPredicate0D::operator()()
  UnaryPredicate1D::operator()()
  BinaryPredicate0D::operator()()
  BinaryPredicate1D::operator()()
  UnaryFunction0D::operator()()
  UnaryFunction1D::operator()()
  StrokeShader.shade()

* Moved part of the introspection-based automatic type conversion code
from BPy_Interface0DIterator.cpp and Director.cpp to BPy_Convert.cpp
for the sake of better code organization.

* Fixed an uninitialized member in StrokeVertexIterator___init__().
2009-07-31 22:13:48 +00:00
6134a41270 Fixed typoes in error messages. 2009-07-31 21:44:59 +00:00
d62f844b12 Fixed typoes in error messages. 2009-07-31 21:44:02 +00:00
4e78dff629 Added Python error handling to StrokeShader::shade(). Also made
a measure to avoid an infinite loop due to non-proper overriding
of the shade method.
2009-07-31 21:03:22 +00:00