Commit Graph

213 Commits

Author SHA1 Message Date
b7b4f94e78 Fix for Freestyle Python API modules not found in the Python Console.
Addition of the path to the Freestyle Python API modules to 'sys.path' was delayed until
the first Freestyle rendering, so that any import attempt of the modules in the Python
Console always failed.  Now the update of 'sys.path' is done at Blender start-up.
This allows the Freestyle-specific modules to be imported without running Freestyle,
facilitating quick interactive testing in the Console.
2014-04-11 16:36:49 +09:00
dfbd994aaf Freestyle: fix for typos in Python API docstrings. 2014-04-09 16:30:44 +09:00
62bf22e27b Freestyle: Removed SVertex _curvatureFredo and _directionFredo and their 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).
2014-04-04 23:47:31 +09:00
a91247c2b4 Code cleanup: unreachable break/return 2014-03-19 12:47:09 +11:00
899caeae49 Freestyle: Fix for a potential implementation error in the Python wrapper of the Nature class. 2014-03-13 21:00:59 +09:00
37cf28b341 Freestyle: avoid checking PyErr_Occurred and quiet warning 2014-03-13 11:54:59 +11:00
26b1406f6e Freestyle: Fix for incorrect comparisons of Nature values with integer and boolean values.
The problem is that comparisons involving the constants Nature.POINT (for vertices) and
Nature.NO_FEATURE (for edges) were evaluated in a wrong way.  It is recalled that the
Nature class is a subclass of Python's built-in int type, and that these two constants are zero
when evaluated as numbers.  The issue was caused by the implementation of the constants
in an incompatible way for comparison with Python int (and boolean) values.  Specifically,
the zero of Python int is represented by an empty array of digits, whereas the zero-valued
Nature constants were represented by an array of size 1.  Python int comparison operators
first check the lengths of the arrays of two operands, and then start comparing the digits
only when the array length is the same.  For this reason, the two Nature constants were
not properly compared with int values (and thus with boolean values).  It is noted that the
zero-valued Nature constants may result from bitwise operations on other Nature constants
(e.g., Nature.SILHOUETTE & Nature.BORDER), so this issue must have affected many
existing style modules.

The problem was reported by Folkert de Vries (flokkievids) through personal communications.
Thanks a lot!
2014-03-05 21:56:38 +09:00
1dc1d92dab Code cleanup: white space and cmake was broken on all platforms 2014-02-03 13:56:34 +11:00
a16998911b 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).
2014-02-02 22:05:32 +09:00
41d778fa5d Docstring updates and code cleanup by flokkievids (Folkert de Vries). 2014-02-02 22:05:31 +09:00
bab88fee20 Code cleanup (mostly indentation and white space). 2014-02-02 22:05:30 +09:00
e9e2813fbe Fix for iterators' at_start flag left unset in C++ to Python conversion utility functions.
Also changed the type of the 'reversed' flag from int to bool.
2014-02-02 22:05:29 +09:00
b58beed604 Imported D222 Diff 2 (ID 781) by flokkievids (Folkert de Vries). 2014-02-02 22:05:28 +09:00
6498b96ce7 Reorganized the Freestyle Python API in a hierarchical package structure.
Both C- and Python-coded API components were rearranged into logical groups.
New Python modules are packaged as follows:

freestyle - Top-level package
freestyle.types - Classes for core data structues (e.g., view map)
freestyle.chainingiterators - Pre-defined chaining iterators
freestyle.functions - Pre-defined 0D and 1D functions
freestyle.predicates - Pre-defined 0D and 1D predicates
freestyle.shaders - Pre-defined stroke shaders
freestyle.utils - Utility functions

The Python modules are installed in scripts/freestyle/modules.  Pre-defined
styles are installed in scripts/freestyle/styles.

To-do: update styles according to the new Freestyle API package structure.
2014-01-28 23:33:57 +09:00
f1a989f9c3 Fix crash in freestyle vector parsing (hard to believe nobody noticed)
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.
2013-12-17 18:01:15 +11:00
b3ea4ec90c Py API: use direct access to list/tuple size when type is known 2013-12-17 16:40:06 +11:00
41e563594d Code Cleanup: int pointer comparison 2013-11-22 08:39:13 +11:00
c592ebf5df Freestyle: a follow-up fix of trunk revision 61233. When an iterator has reached
the end, any reference of the object pointed by it will now lead to a RuntimeError
instead of returning None, with the aim of forcing Python API users to check the
end of iteration rather than implicitly indicating the error condition.

Acknowledgement to flokkievids for API discussions in the BlenderArtists.org
Freestyle for Blender thread.
2013-11-16 22:11:28 +00:00
ef1bc03fce Fix #37092 and #37381: crashes in the .object() method of Freestyle iterators.
Now the method checks if the iterator is at the end, and returns None if that is the case.
2013-11-12 02:28:26 +00:00
8c5597eb49 Additional code improvements: avoid unnecessary Python object allocations in Freestyle. 2013-11-05 00:51:59 +00:00
9575521812 Minor code improvements: avoid unnecessary Python object allocations in Freestyle color blending. 2013-11-03 14:25:37 +00:00
2190e6de0e Fix for missing calls of BaseMath_ReadCallback() when accessing vector/color elements.
This bug was causing wrong color blending results in Freestyle color modifiers.
Problem report from Light BWK through personal communications, thanks!
2013-11-03 14:24:02 +00:00
beae4f498d code cleanup: spelling 2013-10-31 14:10:01 +00:00
7eff2285a3 Fix for Freestyle rendering errors with color blend modes SOFT_LIGHT and LINEAR_LIGHT. 2013-10-31 07:41:40 +00:00
f6b37f34ec code cleanup:
- add missing headers from cmake (own omission)
- quiet rna_test.c unused define warnings.
- minor style edits
- spelling corrections and ignore all uppercase words with spell checking script.
2013-09-05 19:56:49 +00:00
67ae5e8158 Fix for a formatting error in the docstring of SVertex.viewvertex(). 2013-08-07 21:49:11 +00:00
65e7039f8d Fix for docstrings of CurvePoint.first_svertex() and CurvePoint.second_svertex(). 2013-08-07 21:40:59 +00:00
65b932d9f1 Fix for docstring inconsistency in Stroke.stroke_vertices_end(). 2013-07-20 01:45:18 +00:00
15a2287a8e Fix for incorrect clipping of Freestyle strokes when the viewport preview is used. 2013-07-07 15:29:00 +00:00
e5d292604c Fix for splitting at material boundaries not correctly working with border lines.
Problem report by Charblaze in the BlenderArtists.org Freestyle thread, thanks!
2013-06-14 20:43:54 +00:00
7808adbf0c Fix for a crash due to de-referencing of a StrokeVertex Python wrapper object.
Problem report by flokkievids in the BA Freestyle thread, thanks!
2013-05-21 23:11:25 +00:00
6fd12c5310 Added new method Stroke.remove_all_vertices() for removing all vertices from the stroke.
Patch from flokkievids in the BA Freestyle thread, thanks!
2013-05-21 22:59:44 +00:00
30d3a57eb7 Fix for Freestyle built-in style module sketchy_multiple_parameterization.py not working correctly.
Suitable for inclusion in 2.67a.

Logical AND, OR and XOR operations on freestyle.Nature instances gave an error in some cases.
The updated C implementation of these bitwise operations is intended to reproduce the following Python implementation:

class Nature(int):
    def __and__(self, other):
        return Nature(int(self) & int(other))
    def __or__(self, other):
        return Nature(int(self) | int(other))
    def __xor__(self, other):
        return Nature(int(self) ^ int(other))

The problem report was by plasmasolutions on IRC, thanks a lot!
2013-05-16 23:49:05 +00:00
50c46fb9b3 Further fix for memory leaks in Freestyle Python API components:
- StrokeAttribute thickness setter
- BezierCurve (used from within BezierCurveShader)
- Smoother (used from within SmoothingShader)
2013-05-14 22:51:11 +00:00
628bde206f Fix for a copy-and-paste bug in a Freestyle Python API helper function. 2013-05-14 22:16:18 +00:00
1a91af691e Fix for a memory leak during Freestyle stroke shading. 2013-05-13 22:50:12 +00:00
800f86c845 Attempt to fix a potential name conflict between Freestyle and the compositor.
A crash in the Freestyle renderer was reported by Ton on IRC with a stack trace
below.  Note that #2 is in Freestyle, whereas #1 is in the compositor.  The problem
was observed in a debug build on OS X 10.7 (gcc 4.2, openmp disabled, no llvm).

----------------------------------------------------------------------
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: 13 at address: 0x0000000000000000
[Switching to process 72386 thread 0xf303]
0x0000000100c129f3 in NodeBase::~NodeBase (this=0x10e501c80) at COM_NodeBase.cpp:43
43			delete (this->m_outputsockets.back());
Current language:  auto; currently c++
(gdb) where
#0  0x0000000100c129f3 in NodeBase::~NodeBase (this=0x10e501c80) at COM_NodeBase.cpp:43
#1  0x0000000100c29066 in Node::~Node (this=0x10e501c80) at COM_Node.h:49
#2  0x000000010089c273 in NodeShape::~NodeShape (this=0x10e501c80) at NodeShape.cpp:43
#3  0x000000010089910b in NodeGroup::destroy (this=0x10e501da0) at NodeGroup.cpp:61
#4  0x00000001008990cd in NodeGroup::destroy (this=0x10e5014b0) at NodeGroup.cpp:59
#5  0x00000001008990cd in NodeGroup::destroy (this=0x114e18da0) at NodeGroup.cpp:59
#6  0x00000001007e6602 in Controller::ClearRootNode (this=0x114e19640) at Controller.cpp:329
#7  0x00000001007ea52e in Controller::LoadMesh (this=0x114e19640, re=0x10aba4638, srl=0x1140f5258) at Controller.cpp:302
#8  0x00000001008030ad in prepare (re=0x10aba4638, srl=0x1140f5258) at FRS_freestyle.cpp:302
#9  0x000000010080457a in FRS_do_stroke_rendering (re=0x10aba4638, srl=0x1140f5258) at FRS_freestyle.cpp:600
#10 0x00000001006aeb9d in add_freestyle (re=0x10aba4638) at pipeline.c:1584
#11 0x00000001006aceb7 in do_render_3d (re=0x10aba4638) at pipeline.c:1094
#12 0x00000001006ae061 in do_render_fields_blur_3d (re=0x10aba4638) at pipeline.c:1367
#13 0x00000001006afa16 in do_render_composite_fields_blur_3d (re=0x10aba4638) at pipeline.c:1815
#14 0x00000001006b04e4 in do_render_all_options (re=0x10aba4638) at pipeline.c:2021
----------------------------------------------------------------------

Apparently a name conflict between the two Blender modules is taking place.
The present commit hence intends to address it by putting all the Freestyle C++
classes in the namespace 'Freestyle'.  This revision will also prevent potential
name conflicts with other Blender modules in the future.

Special thanks to Lukas Toenne for the help with C++ namespace.
2013-04-09 00:46:49 +00:00
eb495b2a8a use lowercase name for freestyle module (as with all other blender modules). 2013-04-07 11:22:54 +00:00
829a2cc1b0 remove blender foundation copyright from freestyle files.
this can be added back on case-by-case basis, but better not assume ownership of another projects work by default.
2013-03-31 01:11:07 +00:00
ab8c837470 quiet warnings by making undeclared vars static 2013-03-19 10:07:23 +00:00
4a92d82626 A big code clean-up patch from Bastien Montagne, many thanks! 2013-03-07 23:17:23 +00:00
0c5dfc8a63 Fix for exceptions in converting Python float objects to C variables not properly handled.
Based on review comment from Campbell.
2013-03-03 01:53:49 +00:00
3df023ae82 Freestyle Python API improvements - part 8.
* 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.
2013-02-24 02:39:38 +00:00
d38a335d47 Code clean-up and fix for typos in docstrings. 2013-02-24 02:32:56 +00:00
3bd0b89716 Code style clean-up. 2013-02-23 18:50:33 +00:00
ad7c43744c Added GNU GPL header blocks. 2013-02-23 18:32:28 +00:00
7b3a5f6901 Fix for __repr__() depending on .getName() and .getExactTypeName().
API users no longer need to define them in user-defined Functions, Predicates and StrokeShaders.
Also removed all .getName() and .getExactTypeName() definitions in pre-defined Functions,
Predicates and StrokeShaders subclasses.
2013-02-23 12:17:40 +00:00
47960a3d8a Minor docstring fixes. 2013-02-23 03:07:19 +00:00
68b0a8e390 Freestyle Python API improvements - part 7.
Fix for PyGetSetDef and proper handling of keyword arguments were done in
UnaryPredicate0D, UnaryPredicate1D, BinaryPredicate1D, and StrokeShader classes.
Style modules were updated accordingly.  Additional code clean-up was also made.
2013-02-23 01:12:23 +00:00
0fb83d78fa Fixed typoes in docstrings. 2013-02-23 00:44:39 +00:00