Commit Graph

87 Commits

Author SHA1 Message Date
Tamito Kajiyama
865096919d Fixed the feature edge selection by Freestyle face marks to properly account for border edges. 2013-06-16 00:15:05 +00:00
Tamito Kajiyama
829581bbbd Fix for potential division by zero during Freestyle stroke rendering.
Problem report by Light BWK through personal communications with a
sample .blend file for reproducing the problem.  Thanks!
2013-06-02 11:42:04 +00:00
Tamito Kajiyama
b1afee23da Fix for shaders.py based on code review comments from flokkievids.
Only the suggested changes that cause backward incompatibility were considered for now.

* Removed pyFXSThicknessShader that is identical with pyConstantThicknessShader.

* Swapped the order of two arguments of the pyDecreasingThicknessShader constructor
in line with other shaders taking the same arguments.

* Made module functions smoothC and get_fedge into methods of relevant shader classes.

* Removed pyExtremitiesOrientationShader that relied on undefined Stroke methods.
2013-05-03 02:37:43 +00:00
Tamito Kajiyama
ad6cc0d0ac Fix for broken Material color/alpha/thickness modifiers.
Reverted part of the trunk revision 56234 (RNA attribute consistency edits).
2013-04-24 00:14:16 +00:00
Campbell Barton
53917c4e3a rna attribute consistency edits, use common prefix for booleans. 2013-04-23 07:06:29 +00:00
Campbell Barton
eb495b2a8a use lowercase name for freestyle module (as with all other blender modules). 2013-04-07 11:22:54 +00:00
Tamito Kajiyama
5841d1c814 Added header comments to indicate the author(s) of original files.
Suggested by Sergey Sharybin through a code review of the branch.

The information was mostly recovered from the AUTHORS file [1] of the
stand-alone Freestyle package version 2.2.0.

[1] http://freestyle.cvs.sourceforge.net/viewvc/freestyle/freestyle/AUTHORS.TXT
2013-03-24 00:53:05 +00:00
Tamito Kajiyama
dbd0c37119 Removed a global variable from PredicatesU1D.pyNFirstUP1D.
Suggested by Sergey Sharybin through a code review of the branch.
2013-03-19 21:11:45 +00:00
Tamito Kajiyama
21dc9660d9 Fix for missing imported classes in style_modules/contour.py.
Identified by Campbell Barton through a code review of the Freestyle branch.
2013-03-19 20:16:13 +00:00
Tamito Kajiyama
ed053f4730 Fix for the Selection by Image Border not taking account of resolution percentage.
Problem report by octane98 in the BlenderArtists Freestyle thread in June 2012, thanks a lot!
2013-03-15 00:30:20 +00:00
Tamito Kajiyama
b4b2269985 Fix for the Sinus Displacement geometry modifier not working properly.
The problem was caused by keeping a reference to a Vector object that is
assumed to be unchanged, but actually altered by the geometry modifier.

The same code updates were made to similar code portions to prevent
possible future bugs.
2013-03-03 21:56:36 +00:00
Tamito Kajiyama
21c10788d7 Freestyle Python API improvements - part 9.
* Fix for wild card import statements (e.g., "from Freestyle import *") was done.
Now import statements are either without using "from" or with all imported names
explicitly listed.

* GNU GPL header blocks were added to Python programs.  Additional code clean-up
was also made.

* Removed freestyle_init.py and extra-lines.sml that were no longer used.
2013-02-24 23:43:40 +00:00
Tamito Kajiyama
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
Tamito Kajiyama
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
Tamito Kajiyama
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
Tamito Kajiyama
39f8c6e189 Freestyle Python API improvements - part 5.
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.
2013-02-21 02:57:44 +00:00
Tamito Kajiyama
b35a893249 Freestyle Python API improvements - part 4.
Major API updates were made as in part 3 to address code review comments.
This revision focuses on Python wrappers of C++ iterators.

* Most getter/setter methods were reimplemented as attributes using PyGetSetDef.

* 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).  The only irregular naming change is the following, to
better indicate the functionality:

- ChainingIterator: getVertex --> next_vertex

* In addition, some code clean-up was done in both C++ and Python.  Also duplicated
definitions of predicate classes were removed.
2013-02-16 14:21:40 +00:00
Tamito Kajiyama
731d08d497 Freestyle Python API improvements - part 3.
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
2013-02-14 23:48:34 +00:00
Tamito Kajiyama
7e3e3a2270 Freestyle Python API improvements - part 2.
The API syntax of FrsMaterial was updated by means of getter/setter properties.
Python style modules (including the Parameter Editor) were updated accordingly.
2013-02-03 17:01:21 +00:00
Tamito Kajiyama
6ff0d15e5a Freestyle Python API improvements.
StrokeAttribute class methods were renamed from camel case to lower case plus underscore.
Also made changes to shaders.pyTVertexOrientationShader that uses the affected methods.
2013-01-27 21:51:25 +00:00
Tamito Kajiyama
156acd3370 Freestyle Python API improvements - part 1.
* 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.
2013-01-27 20:17:49 +00:00
Tamito Kajiyama
1db5b6d283 Fix for Stroke.Resample(float iSampling) and Stroke.UpdateLength() using
StrokeVertex.point2d() instead of .getPoint().  It is noted that .point2d()
returns a 3-dimensional vector representing a 2D-projected point, with the z
component indicating a normalized depth of the original 3D point, whereas
.getPoint() returns a plain 2-dimensional vector.  This fix should have been
done in revision 48510...

Also made fix for callers of Stroke.Resample() not calling stroke.UpdateLength().
2013-01-22 01:46:16 +00:00
Tamito Kajiyama
ec78eb353f New command-line option --debug-freestyle to enable verbose debug messages
on the console during Freestyle rendering.  The debug prints are turned off
by default now.  Errors are still printed on the console.

A patch set implementing this functionality was provided by Bastien Montagne.
Many thanks! :)
2013-01-03 23:27:20 +00:00
Tamito Kajiyama
acae0e7b1f Further fix for svn:executable. 2012-12-11 23:05:04 +00:00
Tamito Kajiyama
5083e0737f All angle properties were switched from degrees to radians (using PROP_ANGLE
RNA subtype), since Freestyle internally use angles in radians.
A patch set by Bastien Montagne (many thanks!)

NOTICE FOR BRANCH USERS:
This commit may break line drawing settings of already saved Freestyle files.
All angles are now treated as radians instead of degrees, so collections of
angle values might be necessary in order to recover previous visual results.
Affected properties are:
- Crease Angle in the edge detection options
- Min 2D Angle in the 'Splitting' section of a line style
- Max 2D Angle in the 'Splitting' section of a line style
- 'orientation' parameter of the Calligraphy thickness modifier
- 'angle' parameter of the PerlinNoise1D geometry modifier
- 'angle' parameter of the PerlinNoise2D geometry modifier
- 'angle' parameter of the 2DTransform geometry modifier
2012-12-09 23:19:46 +00:00
Tamito Kajiyama
dd633f1aff Fix for dashed line options not working as expected in some applications
when combined with geometry modifiers.

The problem is that users were not able to choose the time when the
dashed line options are applied.  Instead, the dashed line options were
applied only before geometry modifiers were employed.  Since dashes were
separate strokes, the geometry modifiers were processed dash by dash.
Depending on users' artistic intention, this may or may not lead to
expected stylization results, as reported by octane98 in the
BlenderArtists Freestyle thread on January 3, 2012.
http://blenderartists.org/forum/showthread.php?89986-Freestyle-for-Blender&p=2018592&viewfull=1#post2018592

Now the Strokes tab of the Freestyle Line Style panel has two sets of
dashed line options.  One is in the Splitting section of the Strokes tab
and used for splitting strokes by dashed line patterns.  The other set
is called "Dashed Line" and used to generate dashed lines based on the
strokes after the geometry modifiers are applied.  The two sets of
dashed line options are independent of each other, so that users can
enable one of them as well as both at the same time.
2012-11-04 23:52:26 +00:00
Tamito Kajiyama
eabf741a8d Fix for the WithinImageBorderUP1D predicate not working with a ViewEdge such that
none of the SVertices are within the image boundary but an FEdge intersects with
the image boundary.

The problem was reported by edna through the BA Freestyle thread, with a .blend
file for reproducing the bug.  Thanks!
2012-05-28 23:53:28 +00:00
Tamito Kajiyama
19e27ce15b Fix for the Selection by Group not working correctly when the specified group was empty.
Problem report by vicentecarro, with an example .blend file to reproduce the issue. Thanks!
2012-05-04 00:37:06 +00:00
Tamito Kajiyama
826a09300a Added restrictions so as to apply thickness position options (revision 45463)
only when chaining is disable or the Plain chaining is used with the Same Object
option enabled.  The default "center" positioning is used otherwise.
2012-04-08 22:21:48 +00:00
Tamito Kajiyama
67f5ad506b Fix for untested portions in the last commit concerning thickness position options. 2012-04-07 18:16:25 +00:00
Tamito Kajiyama
e94abda66d New options in the Parameter Editor mode for controling the position of stroke thickness.
The new options enable a better control on the position of stroke thickness with
respect to stroke backbone geometry.  Three predefined positions are:
* center: thickness is evenly split to the left and right side of the stroke geometry.
* inside: strokes are drawn within object boundary.
* outside: strokes are drawn outside the object boundary.
Another option called "relative" allows users to specify the relative position by a
number between 0 (inside) and 1 (outside).

The thickness position options are applied only to strokes of the edge types SILHOUETTE
and BORDER, since these are the only edge types defined in terms of object boundary.
Strokes of other edge types are always using the "center" option.
2012-04-07 17:28:09 +00:00
Tamito Kajiyama
eecfa9473c Fix for the Selection by Image Border not working properly.
Problem report by j-mation through the BA Freestyle thread.
2012-02-05 18:42:51 +00:00
Tamito Kajiyama
b0d39d83b9 Unified "Ridge" and "Valley" into "Ridge & Valley" in the Parameter Editor mode.
The Valley edge type is merely an alias of Ridge in the present Freestyle implementation.
2012-02-05 12:50:01 +00:00
Tamito Kajiyama
f88501a44d Added two stroke geometry modifiers:
- 2D Offset: Adds two-dimensional offsets to stroke backbone geometry.
- 2D Transform: Applies two-dimensional scaling and rotation to stroke backbone geometry.
2012-01-04 00:23:34 +00:00
Tamito Kajiyama
32db495e50 Updates on the Parameter Editor mode:
* Added a new chain splitting option for dividing chains into pieces having
a given curvilinear 2D length.

* Rearranged the UI controls of chain splitting options according to the
actual order of processing.

* Made changes for converting each view edge into a chain in the case of
not using chaining.
2011-12-11 23:41:15 +00:00
Tamito Kajiyama
d00b8cfc12 Removed a debug print. 2011-11-14 00:39:39 +00:00
Tamito Kajiyama
99f7f3ac81 Added new options for splitting chains of feature edges by a minimum
and maximum 2D angle.
2011-11-13 20:20:50 +00:00
Tamito Kajiyama
2910427277 Fix for the Perlin Noise 1D geometry modifier having a noise frequency
relative to the stroke length (i.e., the number of noise displacement
values was the same for strokes of different lengths).  This resulted
in very noisy short strokes and much less noisy long strokes.  Now the
noise frequency is relative to the distance from the starting point of
a stroke.  That is, two strokes of the same length will be distorted
by the same number of noise displacement values, whereas longer strokes
will have more noise displacement values along stroke.

Problem report by JO5EF through the BA Freestyle thread, thank you!
2011-11-12 09:02:24 +00:00
Tamito Kajiyama
e7a4d45435 Added to the Parameter Editor mode new stroke geometry modifier `Blueprint'
that produces a blueprint using circular, elliptic, and square contour strokes.
Related changes and bug fixes were made as follows:

* The randomness in radius and center has been transformed into optional
parameters of the pyBluePrintCirclesShader and pyBluePrintEllipsesShader.
Also a new optional parameter to control the randomness of backbone
stretching has been added to the pyBluePrintSquaresShader.

* A bug in the pyBluePrintSquaresShader that invisible stroke vertices at
corners of rectangular contour strokes were not properly drawn.  The problem
was due to the changes of the / operator between Python 2.x to 3.x.  Even
when the two operands of the division operator are integers, Python 3.x
gives a floating-point number when the quotient is not an integer.  The fix
was just to replace the / operator by the // operator for integer division.

* An unpleasant discontinuity in circular and elliptical contour strokes
was fixed.

* The length parameter of the Backbone Stretcher geometry modifier has been
renamed to `backbone_length' in line with the parameter of the same name in
the pyBluePrintSquaresShader.
2011-11-11 20:35:03 +00:00
Tamito Kajiyama
ea11efb082 * Fix for stroke geometry shaders that did not update the 2D length after the
modifications of stroke vertices.

* Fix for a bug in pyBluePrintCirclesShader that did not check the end of
iteration over stroke vertices.

* Fix for stroke vertex removal during iteration over stroke vertices in
pyBluePrintCirclesShader, pyBluePrintEllipsesShader, pyBluePrintSquaresShader,
and pyBluePrintDirectedSquaresShader.
2011-11-01 21:08:18 +00:00
Tamito Kajiyama
ac6bdfb653 Added two stroke geometry modifiers: Parameterization and Guiding Lines. 2011-11-01 09:47:41 +00:00
Tamito Kajiyama
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
Tamito Kajiyama
f0ca79bccb Extended the set of conditions for feature edge selection by edge types.
In the Parameter Editor mode, each edge type check button in the Selection
by Edge Types has now an associated toggle button to exclude the edge type
from the feature edge selection.  This allows you to select, for instance,
those edges that are silhouette lines but not external contours.
2011-10-27 20:57:14 +00:00
Tamito Kajiyama
510c69368b New option for disabling the chaining of feature edges in the Parameter Editor mode. 2011-10-25 23:24:59 +00:00
Tamito Kajiyama
28cc31ba11 Stability improvements for the Face Smoothness option.
The instability considered here is due to a persistent failure of the
getFEdge() method in the Interface0D class and its subclasses in the
presence of smooth FEdges.  When the Face Smoothness option is
enabled, the view map is populated with not only sharp FEdges (i.e.,
edges in the original meshes) but also smooth FEdges (i.e., newly
built edges lying on triangular surfaces).  The failure of getFEdge()
caused many related issues because the method is widely used in other
predicates and functions that rely on it.  The most prominent example
of related user-visible problems is a constant failure of the built-in
MaterialF0D.

The main issue and related problems were addressed as follows:

* A bug in the construction of smooth FEdges was fixed.  Individual
smooth FEdges, even when they were detected as a series of smooth
FEdges that constitute one smooth ViewEdge, may have some irregular
geometry in the form of non-uniform OWXFaceLayer::order values.  The
OWXFaceLayer::order values were used in an inappropriate way, so that
resulting smooth ViewEdges may have an FEdge between two subsequent
SVertices that were indeed the same SVertex object.  This was an
unexpected situation that getFEdge() could not handle.

* Another issue in the construction of smooth FEdges was resolved.
When sharp FEdges are constructed, two SVertices at both ends of an
FEdge are generated only when no SVertex exists in a given 3D position
(this way, the original mesh topology is reconstructed from a bunch of
independent triangles that the BlenderFileLoader class passes to the
view map creation process).  This sharing of SVertices was used also
for the generation of SVertices at the two ends of each smooth FEdge,
causing the getFEdge() failure in the presence of smooth FEdges.  The
workaround implemented here is to simply suppress the sharing of
generated SVertices when smooth FEdges are created.

* In the Parameter Editor mode, the built-in MaterialF0D was replaced
with a better implementation that works well with Curves and Strokes.
MaterialF0D does not work with these 1D data types.
2011-10-10 19:57:06 +00:00
Tamito Kajiyama
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
Tamito Kajiyama
c41e64b9da Changed the behaviour of the Perlin 1D geometry modifier. Now it distorts
strokes using the curvilinear abscissa of stroke vertices as the input of
the Perlin noise generator (instead, the Perlin 2D geometry modifier generates
noise using the 2D coordinates of stroke vertices in the image space as the
input of the noise generator).
2011-09-25 09:50:12 +00:00
Tamito Kajiyama
5582d9fac1 Rearranged the organization of chaining options in line styles.
New there are only two chaining types: plain and sketchy.  Both chaining types
have the "same object" option.  With this option enabled, only feature edges of
the same object are chained.  The sketchy chaining also has the "rounds" option
to specify the number of rounds in a sketchy multiple touch.

Also removed a temporary workaround (implemented by means of a custom chaining
rule) for infinite straight lines, which has resulted in much cleaner strokes.
2011-09-19 23:24:14 +00:00
Tamito Kajiyama
38f24637d4 Added new line style options for sketchy chaining of feature edges.
The default chaining option is now called "Natural", while the new chaining options
are "Sketchy: Topology Preserved" and "Sketchy: Topology broken".  The latter two
options allow for generating chains of feature edges with a sketchy multiple touch.
The "Sketchy: Topology Preserved" option takes account of the topology of objects
in the view map, while the "Sketchy: Topology broken" ignores the edge topology.
The "rounds" option specifies the number of rounds in sketchy strokes.
2011-09-19 22:40:44 +00:00
Tamito Kajiyama
513293a256 Added new line style options for selecting chains by min/max 2D lengths. 2011-09-18 22:59:51 +00:00