Age | Commit message (Collapse) | Author |
|
Needed for clan-format not to wrap onto one line.
|
|
BF-admins agree to remove header information that isn't useful,
to reduce noise.
- BEGIN/END license blocks
Developers should add non license comments as separate comment blocks.
No need for separator text.
- Contributors
This is often invalid, outdated or misleading
especially when splitting files.
It's more useful to git-blame to find out who has developed the code.
See P901 for script to perform these edits.
|
|
|
|
|
|
|
|
|
|
This patch adds some new functionality to the Freestyle Python API, notably:
- MaterialBP1D, checks whether the supplied arguments have the same material
- Fixes a potential crash in CurvePoint.fedge (due to NULL pointer)
- Makes (error handling in) boolean predicates more robust
- Adds a BoundingBox type, to make working with bounding boxes easier
- Adds several new functions (get_object_name, get_strokes, is_poly_clockwise, material_from_fedge)
- Adds a StrokeCollector StrokeShader, that collects all the strokes from a specific call to Operators.create()
- Adds hashing and rich comparison to the FrsMaterial type
These new features (most of them, anyway) are needed for making a more robust SVG exporter that supports holes in fills.
Reviewers: kjym3, campbellbarton
Subscribers: campbellbarton
Projects: #bf_blender
Differential Revision: https://developer.blender.org/D1245
|
|
|
|
Setting all values of a tuple is such a common operation that it deserves its own macro.
Also added Py_INCREF_RET to avoid confusing use of comma operator.
|
|
|
|
Fixed dead references of API identifiers (e.g., freestyle.types.Interface0D)
due to relocations of the identifiers into submodules. Also made various minor
revisions of mark-ups and typos.
|
|
|
|
In addition to D319, this patch updates the parameter editor, the UI of Freestyle.
Using new API functionality and experience gained in making D319, this patch
provides a quite noticable speedup for commonly-used Freestyle linestyle modifiers.
As this patch touches a lot of code (and mainly the foundations) it is likely that
mistakes are made. The patch has been tested with a regression suite for Freestyle
(https://github.com/folkertdev/freestyle-regression-tests/tree/master), but testing
with scenes used in production is very much appreciated.
Differential revision: https://developer.blender.org/D623
Author: flokkievids (Folkert de Vries)
Reviewed by: kjym3 (Tamito Kajiyama)
|
|
|
|
Patch contribution by flokkievids (Folkert de Vries). Thanks!
|
|
Patch contribution by flokkievids (Folkert de Vries). Thanks!
|
|
(See commit e1771e72fbbf828dbf5bed871b814288389f3611 for more detail of
the problem).
Fixed for #include <Python.h> not properly put in the extern "C" { ... } construct.
Also removed redundant inclusion of the header file in the Freestyle Python API code.
|
|
getter/setter methods..
These data elements are undocumented and of little use. For now they are commented out
in the implementation in favor of less memory consumption, and a very limited support for
these data components in the Python API was just removed (should be easy to recover).
|
|
Vectors were being assigned as an array of classes in Vec2f_ptr_from_PyObject and similar functions,
rather then assigning a number to each axis.
|
|
Freestyle.
|
|
|
|
CurvePoint.second_svertex().
|
|
this can be added back on case-by-case basis, but better not assume ownership of another projects work by default.
|
|
|
|
* Proper handling of keyword arguments was implemented in Operators and ContextFunctions,
as well as in methods of Interface0D, Interface1D, Iterator, their subclasses, Noise and
IntegrationType.
* Operators' methods and functions in the ContextFunctions module were renamed from
CamelCase to lower cases + underscores. Style modules were updated accordingly.
* Additional code clean-up was also made.
|
|
|
|
|
|
|
|
Handling of keyword arguments in Python wrapper class constructors was revised.
This revision is mainly focused on Interface0D, Interface1D, Iterator, and
their subclasses, as well as a few additional view map component classes.
Implementation notes: Because of the extensive use of constructor overloading
in the underlying C++ classes, the corresponding Python wrappers try to parse
arguments through multiple calls of PyArg_ParseTupleAndKeywords() if needed.
The downside of this implementation is that most argument errors result in the
same error message ("invalid argument(s)") without indicating what is wrong.
For now this issue is left for future work.
* Now the instantiation of ViewVertex is prohibited since the underlying
C++ class is an abstract class.
* Removed the .cast_to_interface0diterator() method from CurvePointIterator
and StrokeVertexIterator. Instead the constructor of Interface0DIterator now
accepts the instances of these two iterator classes to construct a nested
Interface0DIterator instance that can be passed to Function0D functor objects.
Specifically, an iterator 'it' is passed to a functor 'func' as follows:
func(Interface0DIterator(it))
instead of:
func(it.cast_to_interface0diterator())
* Boolean arguments of class constructors only accept values of boolean type.
Input values of other types are considered as error.
* Additional code clean-up was made.
|
|
|
|
Major API updates were made to address code review comments.
This revision mostly focuses on Python wrappers of C++ 0D and 1D elements (i.e.,
Interface0D and Interface1D, as well as their subclasses).
* Most getter/setter methods were reimplemented as attributes using PyGetSetDef.
Vector attributes are now implemented based on mathutils callbacks. Boolean
attributes now only accept boolean values.
* The __getitem__ method was removed and the Sequence protocol was used instead.
* The naming of methods and attributes was fixed to follow the naming conventions
of the Blender Python API (i.e., lower case + underscores for methods and attributes,
and CamelCase for classes). Some naming inconsistency within the Freestyle Python
API was also addressed.
* The Freestyle API had a number of method names including prefix/suffix "A" and
"B", and their meanings were inconsistent (i.e., referring to different things
depending on the classes). The names with these two letters were replaced with
more straightforward names. Also some attribute names were changed so as to indicate
the type of the value (e.g., FEdge.next_fedge instead of FEdge.next_edge) in line
with other names explicitly indicating what the value is (e.g., SVertex.viewvertex).
* In addition, some code clean-up was done in both C++ and Python.
Notes:
In summary, the following irregular naming changes were made through this revision
(those resulting from regular changes of naming conventions are not listed):
- CurvePoint: {A,B} --> {first,second}_svertex
- FEdge: vertex{A,B} --> {first,second}_svertex
- FEdge: {next,previous}Edge --> {next,previous}_fedge
- FEdgeSharp: normal{A,B} --> normal_{right,left}
- FEdgeSharp: {a,b}FaceMark --> face_mark_{right,left}
- FEdgeSharp: {a,b}Material --> material_{right,left}
- FEdgeSharp: {a,b}MaterialIndex --> material_index_{right,left}
- FrsCurve: empty --> is_empty
- FrsCurve: nSegments --> segments_size
- TVertex: mate() --> get_mate()
- ViewEdge: fedge{A,B} --> {first,last}_fedge
- ViewEdge: setaShape, aShape --> occlude
- ViewEdge: {A,B} --> {first,last}_viewvertex
- ViewMap: getScene3dBBox --> scene_bbox
|
|
N-dimensional float array.
* Local helpers were replaced with the generic one. This also fixed a memory leak in the setter
function StrokeVertex_point_set.
* Made minor code style changes.
|
|
|
|
* The API syntax of StrokeVertex and StrokeAttribute was updated by means of getter/setter
properties instead of class methods. Python style modules (including the Parameter Editor
implementation) were updated accordingly.
* Code clean-up was done for a few Python style modules, mostly by removing duplicated
definitions of stroke shaders and fixing indentation.
|
|
information at a given SVertex.
|
|
* 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().
|
|
was added to the docstrings of most Python extension types.
|
|
extension classes. Copy constructors should be used to duplicate
objects.
|
|
|
|
(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.
|
|
in the definitions of Python wrappers.
|
|
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.
|
|
|
|
types: Interface0D, SVertex, ViewVertex, StrokeVertex, NonTVertex,
and TVertex.
|
|
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
|
|
|
|
* 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__().
|
|
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.
|
|
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__().
|
|
Now the following methods in the Freestyle Python API accept
not only Blender.Mathutils.Vector instances but also lists and
tuples having an appropriate number of elements.
FrsNoise::turbulence2()
FrsNoise::turbulence3()
FrsNoise::smoothNoise2()
FrsNoise::smoothNoise3()
SVertex::__init__()
SVertex::setPoint3D()
SVertex::setPoint2D()
SVertex::AddNormal()
FEdgeSharp::setNormalA()
FEdgeSharp::setNormalB()
FEdgeSmooth::setNormal()
CalligraphicShader::__init__()
StrokeAttribute::setAttributeVec2f()
StrokeAttribute::setAttributeVec3f()
StrokeAttribute::setColor()
StrokeVertex::setPoint()
* Added the following converters for the sake of the improvements
mentioned above.
Vec2f_ptr_from_PyObject()
Vec3f_ptr_from_PyObject()
Vec3r_ptr_from_PyObject()
Vec2f_ptr_from_PyList()
Vec3f_ptr_from_PyList()
Vec3r_ptr_from_PyList()
Vec2f_ptr_from_PyTuple()
Vec3f_ptr_from_PyTuple()
Vec3r_ptr_from_PyTuple()
Those converters with the suffixes _PyList and _PyTuple accept
only lists and tuples having an appropriate number of elements,
respectively, while those with the suffix _PyObject accept lists,
tuples, or Blender.Mathutils.Vector instances.
* Fixed a null pointer reference in Interface0D___dealloc__().
* Corrected the names of 3 methods in the FEdgeSmooth class.
|