10 years agoMerged
Tamito Kajiyama [Fri, 18 Sep 2009 22:25:49 +0000 (22:25 +0000)]
Merged (r22789) and (r23338)
with the "Ignore ancestry" and "Ignore line endings" options enabled (using
TortoiseSVN on Windows).

After the merge operation, all changes (i.e., deletion) in source/blender/freestyle/
were reverted in order to keep the primary source tree of the Freestyle renderer.

10 years agoMade an attempt to fix a crash due to undo. An undo invalidated
Tamito Kajiyama [Tue, 25 Aug 2009 23:46:00 +0000 (23:46 +0000)]
Made an attempt to fix a crash due to undo.  An undo invalidated
some Freestyle-related pointers, which led to a crash when the
rendering was initiated or the Freestyle panel (in the Scene buttons)
was redrawn.

10 years agoFixed a crash due to a missing call for FRS_initialize in the case
Tamito Kajiyama [Tue, 25 Aug 2009 01:12:23 +0000 (01:12 +0000)]
Fixed a crash due to a missing call for FRS_initialize in the case
of running Blender in the background rendering mode using the '-b'
command option.

10 years agoFixed a bug in PythonInterpreter::interpretFile() that a temporary
Tamito Kajiyama [Sun, 23 Aug 2009 16:03:12 +0000 (16:03 +0000)]
Fixed a bug in PythonInterpreter::interpretFile() that a temporary
text object storing a Python script was not properly freed when an
error occurred during the execution of the script.

10 years agoFixed refcount issues in the Python API.
Tamito Kajiyama [Sat, 8 Aug 2009 16:28:10 +0000 (16:28 +0000)]
Fixed refcount issues in the Python API.

10 years agoAdded missing #include <typeinfo> to BPy_Convert.h.
Tamito Kajiyama [Sat, 8 Aug 2009 11:18:40 +0000 (11:18 +0000)]
Added missing #include <typeinfo> to BPy_Convert.h.

10 years agoFixed compiler errors (tested with VC++ 2009 Express Edition, CMake 2.6.3).
Tamito Kajiyama [Tue, 4 Aug 2009 09:48:54 +0000 (09:48 +0000)]
Fixed compiler errors (tested with VC++ 2009 Express Edition, CMake 2.6.3).

10 years agoRemoved unnecessary initialization argument
Maxime Curioni [Tue, 4 Aug 2009 01:08:00 +0000 (01:08 +0000)]
Removed unnecessary initialization argument

10 years agoRemoved unnecessary initialization
Maxime Curioni [Tue, 4 Aug 2009 00:59:29 +0000 (00:59 +0000)]
Removed unnecessary initialization

10 years agoSUMMARY:
Maxime Curioni [Tue, 4 Aug 2009 00:40:36 +0000 (00:40 +0000)]
The main contribution of this commit is the possibility to save Freestyle configuration information inside .blend files. It required an extensive refactoring of the previous interface code.

The code has been tested and does not crash on my machine. If you encounter issues, please let me know (and if possible, sending me an sample .blend file).

- refactored code to notify Freestyle when adding/removing render layers  (FRS_freestyle_config.{h,cpp})
- corrected the freeing of style modules when files are read from / written to disk
- moved Freestyle configuration information into scene renderlayers, to allow loading / saving .blend files (DNA_scene_types.h DNA_freestyle_types.h FRS_freestyle.cpp)
- inserted temporary trick to prevent crashes when orthographic camera is used (SilhouetteGeomEngine.cpp), but outputting incorrect feature line calculations

10 years agoFixed argument checking in __init__ methods of Interface1D, Predicates,
Tamito Kajiyama [Mon, 3 Aug 2009 15:19:51 +0000 (15:19 +0000)]
Fixed argument checking in __init__ methods of Interface1D, Predicates,
Functions, and StrokeShader types.

10 years ago* Fixed uninitialized pointers in "__init__" methods of UnaryFunction1D types.
Tamito Kajiyama [Mon, 3 Aug 2009 14:38:15 +0000 (14:38 +0000)]
* 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: runTest (__main__.UnaryFunction1DDoubleInitTestCase)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "", line 211, in runTest
> TypeError: an integer is required
> ----------------------------------------------------------------------

* Also removed unnecessary error messages in "__init__" methods of
UnaryFunction1D types.

10 years agoFixed the handling of constructor arguments in the following Python
Tamito Kajiyama [Sun, 2 Aug 2009 22:39:21 +0000 (22:39 +0000)]
Fixed the handling of constructor arguments in the following Python
types: Interface0D, SVertex, ViewVertex, StrokeVertex, NonTVertex,
and TVertex.

10 years agoSWIG/directors dependency removal (cont'd)
Tamito Kajiyama [Sun, 2 Aug 2009 19:36:18 +0000 (19:36 +0000)]
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:

    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

    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

    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

10 years agoFixed the argument parsing in CurvePoint.__init__().
Tamito Kajiyama [Sun, 2 Aug 2009 18:25:26 +0000 (18:25 +0000)]
Fixed the argument parsing in CurvePoint.__init__().

10 years ago* Fixed __init__() method so as to corecttly handle arguments.
Tamito Kajiyama [Sun, 2 Aug 2009 17:38:51 +0000 (17:38 +0000)]
* 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.

10 years agoSWIG/directors dependency removal (cont'd)
Tamito Kajiyama [Sun, 2 Aug 2009 16:23:18 +0000 (16:23 +0000)]
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

* 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

  // 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:


* 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

10 years agoChanged the type of returned value of BPy_directedViewEdge_from_directedViewEdge()
Tamito Kajiyama [Sat, 1 Aug 2009 18:03:43 +0000 (18:03 +0000)]
Changed the type of returned value of BPy_directedViewEdge_from_directedViewEdge()
from list to tuple.

10 years agoDisabled the Python wrapper of ViewVertex::edgesEnd(), since the
Tamito Kajiyama [Fri, 31 Jul 2009 23:49:12 +0000 (23:49 +0000)]
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.

10 years agoAdded boundary checking to Iterator::increment() and Iterator::decrement()
Tamito Kajiyama [Fri, 31 Jul 2009 23:16:38 +0000 (23:16 +0000)]
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.

10 years ago* Implemented Python's iterator protocol in Interface0DIterator and
Tamito Kajiyama [Fri, 31 Jul 2009 22:13:48 +0000 (22:13 +0000)]
* Implemented Python's iterator protocol in Interface0DIterator and

* 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.


* 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__().

10 years agoFixed typoes in error messages.
Tamito Kajiyama [Fri, 31 Jul 2009 21:44:59 +0000 (21:44 +0000)]
Fixed typoes in error messages.

10 years agoFixed typoes in error messages.
Tamito Kajiyama [Fri, 31 Jul 2009 21:44:02 +0000 (21:44 +0000)]
Fixed typoes in error messages.

10 years agoAdded Python error handling to StrokeShader::shade(). Also made
Tamito Kajiyama [Fri, 31 Jul 2009 21:03:22 +0000 (21:03 +0000)]
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.

10 years agoAdded minor changes.
Tamito Kajiyama [Wed, 29 Jul 2009 18:49:03 +0000 (18:49 +0000)]
Added minor changes.

10 years agoAdded changes to the AdjacencyIterator type to support Python's
Tamito Kajiyama [Wed, 29 Jul 2009 00:18:13 +0000 (00:18 +0000)]
Added changes to the AdjacencyIterator type to support Python's
iterator protocol.  Now the following code in the conventional
SWIG-based syntax:

    it = AdjacencyIterator(iter)
    while not it.isEnd():
        ve = it.getObject()

can be written using the iterator protocol as follows:

    for ve in AdjacencyIterator(iter):

10 years agoImplemented a measure to avoid an infinite loop triggered when
Tamito Kajiyama [Wed, 29 Jul 2009 00:11:41 +0000 (00:11 +0000)]
Implemented a measure to avoid an infinite loop triggered when
ChainingIterator::init() and ChainingIterator::traverse() were
not properly overloaded in a subclass.

10 years agoReplaced missing integrateDouble() by integrate() newly implemented
Tamito Kajiyama [Tue, 28 Jul 2009 00:34:22 +0000 (00:34 +0000)]
Replaced missing integrateDouble() by integrate() newly implemented
in revision 21954.

10 years ago* BPy_IntegrationType.cpp: Added a Python wrapper of integrate function.
Tamito Kajiyama [Tue, 28 Jul 2009 00:29:30 +0000 (00:29 +0000)]
* BPy_IntegrationType.cpp: Added a Python wrapper of integrate function.

* Fixed uninitialized fields in the "__init__" methods of UnaryFunction0D
types.  Also added missing argument validation codes to some of the types,
and removed redundant validation error messages.

10 years ago* Removed all classes for wrapping extension types.
Tamito Kajiyama [Mon, 27 Jul 2009 20:13:47 +0000 (20:13 +0000)]
* Removed all classes for wrapping extension types.
This allows users to test the types of those objects that are returned
by API functions, by means of usual Python idioms such as "type(I) is T"
and "isinstance(I, T)".

* Removed all occurrences of ViewVertex::castToTVertex() in the following
modules and rewrote the code segments using it by means of the "type(I)
is T" idiom mentioned above:

* Replaced all occurrences of vector.Vec2, vector.Vec3, Vec2f and Vec3f
by Blender.Mathutils.Vector in the following modules:

* Fixed NameError's concerning math.pow().

* Added a Python equivalent of getFEdge function, defined
in source\blender\freestyle\intern\view_map\Functions0D.cpp as follows:

  FEdge* Functions0D::getFEdge(Interface0D& it1, Interface0D& it2) {
    return it1.getFEdge(it2);

* Replaced fe.qi() by fe.viewedge().qi().

* Fixed the import statement for

10 years ago* Fixed compiler errors in UnaryFunction0DVectorViewShape::__call__()
Tamito Kajiyama [Mon, 27 Jul 2009 19:34:52 +0000 (19:34 +0000)]
* Fixed compiler errors in UnaryFunction0DVectorViewShape::__call__()
and UnaryFunction1DVectorViewShape::__call__().

* Added a Python wrapper of ViewEdge::qi().

10 years agoChanged DIR_SEP for WIN32 from "\\\\" (double backslashes) to
Tamito Kajiyama [Mon, 27 Jul 2009 19:31:24 +0000 (19:31 +0000)]
Changed DIR_SEP for WIN32 from "\\\\" (double backslashes) to
"\\" (single backslash).

10 years agoSecond attempt to fix a null pointer reference in deallocators of
Tamito Kajiyama [Sun, 26 Jul 2009 20:20:25 +0000 (20:20 +0000)]
Second attempt to fix a null pointer reference in deallocators of
built-in types (the first was in revision 21877).  When an exception
has raised within from the __init__ method of a user-defined class
derived from a built-in type (e.g., UnaryPredicate0D and
BinaryPredicate1D), some member variables of the base type are
left uninitialized, leading to a null pointer reference in the
"__dealloc__" function in the base type.  To avoid this, pointer
checking was added in the deallocators of those built-in types that
can be used to define a subclass by a user.

10 years agoReverted the change in revision 21877 in Interface0D___dealloc__().
Tamito Kajiyama [Sun, 26 Jul 2009 17:29:25 +0000 (17:29 +0000)]
Reverted the change in revision 21877 in Interface0D___dealloc__().

10 years agoMade predicate and function types callable in the sense that
Tamito Kajiyama [Sun, 26 Jul 2009 16:15:28 +0000 (16:15 +0000)]
Made predicate and function types callable in the sense that
callable(I, T) returns True when I is an object of a type T or
of a subtype of T.  Also implemented a measure to avoid an
infinite loop when user-defined predicate and function classes
do not properly overload the __call__ method (including the
cases of directly instantiating the base classes such as
UnaryPredicate0D and BinaryPredicate1D).

10 years agoImplemented Python wrappers of context functions (such as GetTimeStampCF).
Tamito Kajiyama [Sun, 26 Jul 2009 11:19:37 +0000 (11:19 +0000)]
Implemented Python wrappers of context functions (such as GetTimeStampCF).

10 years agoFixed a problem related to AdjacencyIterator. In the Python layer,
Tamito Kajiyama [Sat, 25 Jul 2009 18:02:34 +0000 (18:02 +0000)]
Fixed a problem related to AdjacencyIterator.  In the Python layer,
AdjacencyIterator::isBegin() and AdjacencyIterator::isEnd() always
returned a False value and printed a "not implemented" warning message.
This caused an infinite loop in a few chaining iterators, resulting in
a crash of the program.  The origin of the issue seemed to be a fact
that in the C++ layer, the AdjacencyIterator class had not properly
overloaded the definitions of the methods in the Iterator superclass.
The fix here looks okay, although I'm not sure why this inconsistency
was not addressed for a long time.

10 years ago* Better support for vector-like objects in method arguments.
Tamito Kajiyama [Sat, 25 Jul 2009 11:27:18 +0000 (11:27 +0000)]
* Better support for vector-like objects in method arguments.
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.


* Added the following converters for the sake of the improvements
mentioned above.


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.

10 years agoFixed a minor memory leak in Controller::LoadMesh().
Tamito Kajiyama [Sat, 25 Jul 2009 10:44:10 +0000 (10:44 +0000)]
Fixed a minor memory leak in Controller::LoadMesh().

10 years agoFixed compiler errors caused by the changes in revision 21700.
Tamito Kajiyama [Fri, 24 Jul 2009 23:34:25 +0000 (23:34 +0000)]
Fixed compiler errors caused by the changes in revision 21700.

10 years agoSecond attempt for properly releasing temporary objects and their data
Tamito Kajiyama [Wed, 22 Jul 2009 23:27:10 +0000 (23:27 +0000)]
Second attempt for properly releasing temporary objects and their data
blocks in BlenderStrokeRenderer::~BlenderStrokeRenderer().

10 years agoMade changes for releasing temporary objects and their data blocks
Tamito Kajiyama [Wed, 22 Jul 2009 00:01:34 +0000 (00:01 +0000)]
Made changes for releasing temporary objects and their data blocks
in BlenderStrokeRenderer::~BlenderStrokeRenderer().

10 years agoFixed a refcount bug concerning ChainPredicateIterator.
Tamito Kajiyama [Tue, 21 Jul 2009 19:44:15 +0000 (19:44 +0000)]
Fixed a refcount bug concerning ChainPredicateIterator.

10 years ago* Introspection-based automatic type conversion from a generic C++ object
Tamito Kajiyama [Sun, 19 Jul 2009 23:17:30 +0000 (23:17 +0000)]
* Introspection-based automatic type conversion from a generic C++ object
to a specific Python object.  The conversion takes place in the following
- Interface0DIterator_getObject (BPy_Interface0DIterator.cpp)
- Director_BPy_BinaryPredicate1D___call__ (Director.cpp)
- Director_BPy_UnaryPredicate1D___call__ (Director.cpp)
- SVertex_viewvertex (BPy_SVertex.cpp)
- BPy_FEdge_from_FEdge (BPy_Convert.cpp)
This is a tentative list and more conversions are expected to be added.

* Added the following two converter functions to BPy_Convert.{cpp,h}:
- BPy_NonTVertex_from_NonTVertex_ptr
- BPy_TVertex_from_TVertex_ptr

10 years agoAdded a missing wrapper for AdjacencyIterator::isIncoming().
Tamito Kajiyama [Sun, 19 Jul 2009 23:03:26 +0000 (23:03 +0000)]
Added a missing wrapper for AdjacencyIterator::isIncoming().

10 years agoFixed uninitialized pointers in ViewVertex instances returned by the
Tamito Kajiyama [Sun, 19 Jul 2009 23:01:25 +0000 (23:01 +0000)]
Fixed uninitialized pointers in ViewVertex instances returned by the
castToViewVertex method.

10 years agoFixed uninitialized pointers in Interface0DIterator instances returned by
Tamito Kajiyama [Sun, 19 Jul 2009 16:37:55 +0000 (16:37 +0000)]
Fixed uninitialized pointers in Interface0DIterator instances returned by
the castToInterface0DIterator method.

10 years agoFixed a bug that the parameter panel did not correctly work when
Tamito Kajiyama [Sat, 18 Jul 2009 18:33:07 +0000 (18:33 +0000)]
Fixed a bug that the parameter panel did not correctly work when
a new file was created or an existing file was loaded.

10 years agoSimplified modelview matrix copy (take 2)
Maxime Curioni [Sun, 12 Apr 2009 07:12:59 +0000 (07:12 +0000)]
Simplified modelview matrix copy (take 2)

10 years agoSimplified modelview matrix copy
Maxime Curioni [Sun, 12 Apr 2009 07:02:03 +0000 (07:02 +0000)]
Simplified modelview matrix copy

10 years agoCorrected memory deallocation error on exit
Maxime Curioni [Wed, 8 Apr 2009 23:03:46 +0000 (23:03 +0000)]
Corrected memory deallocation error on exit

10 years agoCorrected the problem of the view moving after a Freestyle render, when positioned...
Maxime Curioni [Wed, 8 Apr 2009 21:44:38 +0000 (21:44 +0000)]
Corrected the problem of the view moving after a Freestyle render, when positioned at the camera location

10 years agoMade the calculation of the number of available style modules more robust
Maxime Curioni [Wed, 8 Apr 2009 20:19:20 +0000 (20:19 +0000)]
Made the calculation of the number of available style modules more robust

10 years agoCorrected crash when calculating number of available style modules
Maxime Curioni [Wed, 8 Apr 2009 17:32:56 +0000 (17:32 +0000)]
Corrected crash when calculating number of available style modules

10 years agoSUMMARY:
Maxime Curioni [Tue, 7 Apr 2009 18:38:23 +0000 (18:38 +0000)]
Freestyle's pipeline is now fully controllable at the layer level. It can be used:
 - in any render layer
 - with as many style modules per layer

Freestyle usage has not changed:
  - all the configuration happens in the "Freestyle" render panel, after it is enabled in the "Output" panel with the 'Freestyle' toggle.
  - each render layer can choose to render Freestyle strokes by togglingo on 'FrSt' (in the "Render Layers" panel)
  - it is fully compatible with compositor nodes

In the "Freestyle" panel, a render layer is selected via the menu list next to the "Render Layer:" label. The options displayed below are those of the currently selected render layer (and are not global to all render layers, as was previously the case).

Style modules are added by pressing the lower button "Add style module". Once added, the following operations are possible:
- deletion (cross)
- reordering (up/down arrows)
- toggling of display (check)

The order of the style modules follows Freestyle's original convention: the modules in the list from top to bottom are respectively the first to the last composited in the render layer. For example, if the module list is "contour" followed by "cartoon", the "cartoon" strokes are rendered on top of the "contour" strokes.

The "Freestyle" panel is constantly synchronized with the "Render Layers" panel: if render layers are added, deleted or toggled off display, Freestyle will take note of the changes.

The current pipeline works as follows:

for every scene that is being rendered
if Freestyle is enabled globally

Freestyle is initialized
camera and view settings are transferred from Blender to Freestyle

for every render layer
if: - layer is enabled
    - layer enabled Freestyle
    - the number of displayed style modules is non-zero

canvas is cleared
geometry is transferred from Blender to Freestyle
settings are fixed for current iteration
view map is calculated

strokes are computed in the canvas (based on view map and style modules)
strokes are rendered in separate Blender scene

scene is composited in current layer

A number of changes were made on the codebase:
- the rendering interface between Freestyle and Blender was simplified. The following naming convention was used: functions that are called from within Blender pipeline are prefixed with 'FRS_', while the variables are prefixed with 'freestyle_'
- Freestyle data structures that were put in Blender's render pipeline were removed
- Freestyle cleans up its data structures on Blender exit and shouldn't leak memory
- to ease the configuration in the "Freestyle" panel, a centralized configuration data structure was used and can be easily extended

Even though the current commit is stable and achieves the intended result, it is not as efficient as it could be:
- the canvas and the style modules are at cleared at each layer-level render
- geometry is reloaded at each frame and is duplicated across render layers

This revision clarifies my understanding of the future role of the view map in the compositor. Unfortunately, contrary to what the original proposal said, it is impossible to provide the view map as a render pass because render passes are defined (RE_pipeline.h) as raw floating-point rects. We will have to determine whether or not to extend the notion of render pass to fully integrate the view map in the compositor.

10 years agoTweaked a preprocessor conditional statement to support MinGW
Tamito Kajiyama [Sun, 5 Apr 2009 16:20:41 +0000 (16:20 +0000)]
Tweaked a preprocessor conditional statement to support MinGW
(tested with gcc version 3.4.5 (mingw-vista special r3), SCons
1.2.0, and Python 2.5.2).

10 years agoImprovements on error handling in the Python API.
Tamito Kajiyama [Sat, 4 Apr 2009 15:26:12 +0000 (15:26 +0000)]
Improvements on error handling in the Python API.

10 years agoRelaxed type checking concerning boolean arguments so that not only
Tamito Kajiyama [Sat, 4 Apr 2009 14:50:54 +0000 (14:50 +0000)]
Relaxed type checking concerning boolean arguments so that not only
True and False but also various other boolean expressions (e.g., 0,
1, and None) are accepted.

10 years agoRelaxed type checking concerning boolean arguments in class constructors
Tamito Kajiyama [Fri, 3 Apr 2009 20:03:09 +0000 (20:03 +0000)]
Relaxed type checking concerning boolean arguments in class constructors
and __call__ methods so that not only True and False but also various
other boolean expressions (e.g., 0, 1, and None) are accepted.

10 years agoFixed an error checking in Curvature2DAngleF0D::operator().
Tamito Kajiyama [Thu, 2 Apr 2009 19:28:14 +0000 (19:28 +0000)]
Fixed an error checking in Curvature2DAngleF0D::operator().
Now the function results in 0 (radian) if the given Interface0DIterator
object has only 2 vertices, which is not considered an error.

10 years agoAdded getExactTypeName() method.
Tamito Kajiyama [Wed, 1 Apr 2009 01:21:11 +0000 (01:21 +0000)]
Added getExactTypeName() method.

10 years agoImprovements on error handling in the Python API.
Tamito Kajiyama [Tue, 31 Mar 2009 22:45:11 +0000 (22:45 +0000)]
Improvements on error handling in the Python API.

10 years ago* fixed uninitialized variables.
Tamito Kajiyama [Mon, 30 Mar 2009 19:25:27 +0000 (19:25 +0000)]
* fixed uninitialized variables.
* fixed a bug that was introduced in the last commit.

10 years agoImprovements on error handling in the Python API.
Tamito Kajiyama [Sun, 29 Mar 2009 21:50:10 +0000 (21:50 +0000)]
Improvements on error handling in the Python API.

10 years ago* improved error handling in CurvePointIterator constructor.
Tamito Kajiyama [Sun, 29 Mar 2009 21:05:03 +0000 (21:05 +0000)]
* improved error handling in CurvePointIterator constructor.
* changed CurvePointIterator::getObject() according to the changes
in revision 19456.

10 years ago* Added BPy_Chain_from_Chain_ptr().
Tamito Kajiyama [Sun, 29 Mar 2009 21:00:26 +0000 (21:00 +0000)]
* Added BPy_Chain_from_Chain_ptr().
* Changed BPy_CurvePoint_from_CurvePoint( CurvePoint& cp ) to
BPy_CurvePoint_from_CurvePoint_ptr( CurvePoint *cp ) so that it
retains a CurvePoint pointer instead of a CurvePoint instance.

10 years agoFixed a typo in the last commit.
Tamito Kajiyama [Sun, 29 Mar 2009 18:46:17 +0000 (18:46 +0000)]
Fixed a typo in the last commit.

10 years agoImprovements on error handling in the Python API.
Tamito Kajiyama [Sun, 29 Mar 2009 17:44:14 +0000 (17:44 +0000)]
Improvements on error handling in the Python API.

10 years agoFreestyle was changed from a tile-based process to a post-processing effect. This...
Maxime Curioni [Sun, 22 Mar 2009 16:25:14 +0000 (16:25 +0000)]
Freestyle was changed from a tile-based process to a post-processing effect. This will allow style modules to process the underlying color buffer ( AppCanvas::readColorPixels ) and depth buffer ( AppCanvas::readDepthPixels ), as was supported in the original program.

Corrected crash when Freestyle is rendered in "Single" render layer mode (for example, in the compositor)

10 years agoRemoved the declaration of an undefined static function, to suppress a compiler warning.
Tamito Kajiyama [Sat, 21 Mar 2009 12:09:58 +0000 (12:09 +0000)]
Removed the declaration of an undefined static function, to suppress a compiler warning.
Also made minor changes to make IntegrationType a subclass of the built-in int type.

10 years agoCorrected stroke/Operators.cpp to compile without warnings
Maxime Curioni [Sat, 21 Mar 2009 04:51:51 +0000 (04:51 +0000)]
Corrected stroke/Operators.cpp to compile without warnings
Cleaned up comments

10 years agoFixed editing errors in the last commit...
Tamito Kajiyama [Fri, 20 Mar 2009 23:19:47 +0000 (23:19 +0000)]
Fixed editing errors in the last commit...

10 years agoMade changes to the C++ API in order to allow for proper error
Tamito Kajiyama [Fri, 20 Mar 2009 22:55:07 +0000 (22:55 +0000)]
Made changes to the C++ API in order to allow for proper error
propagation up to the toplevel error handler in BPY_txt_do_python_Text().

Before these changes were made, the operator() methods of predicates
and functions, for example, returned a value of various types such as
bool, double and Vec2f.  These returned values were not capable to
represent an error state in many cases.

Now the operator() methods always return 0 on normal exit and -1 on
error.  The original returned values are stored in the "result" member
variables of the predicate/function classes.

This means that if we have a code fragment like below:

  UnaryPredicate1D& pred;
  Interface1D& inter;
  if (pred(inter)) {
    /* do something */

then we have to rewrite it as follows:

  UnaryPredicate1D& pred;
  Interface1D& inter;
  if (pred(inter) < 0)
    return -1; /* an error in pred() is propagated */
  if (pred.result) {
    /* do something */

Suppose that pred is a user-defined predicate in Python, i.e. the predicate
is likely error-prone (especially when debugging the predicate).  The first
code fragment shown above prevents the proper error propagation because
the boolean return value of UnaryPredicate1D::operator() cannot inform the
occurrence of an error to the caller; the second code fragment can.

In addition to the operator() methods of predicates and functions, similar
improvements have been made to all other C++ API functions and methods that
are involved in the execution of user-defined Python code snippets.  Changes
in the signatures of functions and methods are summarized as follows (note
that all subclasses of listed classes are also subject to the changes).

Old signatures:
virtual void Iterator::increment();
virtual void Iterator::decrement();
virtual void ChainingIterator::init();
virtual ViewEdge * ChainingIterator::traverse(const AdjacencyIterator &it);
static void Operators::select(UnaryPredicate1D& pred);
static void Operators::chain(ViewEdgeInternal::ViewEdgeIterator& it,
    UnaryPredicate1D& pred, UnaryFunction1D_void& modifier);
static void Operators::chain(ViewEdgeInternal::ViewEdgeIterator& it,
    UnaryPredicate1D& pred);
static void Operators::bidirectionalChain(ChainingIterator& it,
    UnaryPredicate1D& pred);
static void Operators::bidirectionalChain(ChainingIterator& it);
static void Operators::sequentialSplit(UnaryPredicate0D& startingPred,
    UnaryPredicate0D& stoppingPred, float sampling = 0);
static void Operators::sequentialSplit(UnaryPredicate0D& pred, float sampling = 0);
static void Operators::recursiveSplit(UnaryFunction0D<double>& func,
    UnaryPredicate1D& pred, float sampling = 0);
static void Operators::recursiveSplit(UnaryFunction0D<double>& func,
    UnaryPredicate0D& pred0d, UnaryPredicate1D& pred, float sampling = 0);
static void Operators::sort(BinaryPredicate1D& pred);
static void Operators::create(UnaryPredicate1D& pred, vector<StrokeShader*> shaders);
virtual bool UnaryPredicate0D::operator()(Interface0DIterator& it);
virtual bool BinaryPredicate0D::operator()(Interface0D& inter1, Interface0D& inter2);
virtual bool UnaryPredicate1D::operator()(Interface1D& inter);
virtual bool BinaryPredicate1D::operator()(Interface1D& inter1, Interface1D& inter2);
virtual void StrokeShader::shade(Stroke& ioStroke) const;
virtual T UnaryFunction0D::operator()(Interface0DIterator& iter);
virtual T UnaryFunction1D::operator()(Interface1D& inter);

New signatures:
virtual int Iterator::increment();
virtual int Iterator::decrement();
virtual int ChainingIterator::init();
virtual int ChainingIterator::traverse(const AdjacencyIterator &it);
static int Operators::select(UnaryPredicate1D& pred);
static int Operators::chain(ViewEdgeInternal::ViewEdgeIterator& it,
   UnaryPredicate1D& pred, UnaryFunction1D_void& modifier);
static int Operators::chain(ViewEdgeInternal::ViewEdgeIterator& it,
   UnaryPredicate1D& pred);
static int Operators::bidirectionalChain(ChainingIterator& it,
   UnaryPredicate1D& pred);
static int Operators::bidirectionalChain(ChainingIterator& it);
static int Operators::sequentialSplit(UnaryPredicate0D& startingPred,
   UnaryPredicate0D& stoppingPred, float sampling = 0);
static int Operators::sequentialSplit(UnaryPredicate0D& pred, float sampling = 0);
static int Operators::recursiveSplit(UnaryFunction0D<double>& func,
   UnaryPredicate1D& pred, float sampling = 0);
static int Operators::recursiveSplit(UnaryFunction0D<double>& func,
   UnaryPredicate0D& pred0d, UnaryPredicate1D& pred, float sampling = 0);
static int Operators::sort(BinaryPredicate1D& pred);
static int Operators::create(UnaryPredicate1D& pred, vector<StrokeShader*> shaders);
virtual int UnaryPredicate0D::operator()(Interface0DIterator& it);
virtual int BinaryPredicate0D::operator()(Interface0D& inter1, Interface0D& inter2);
virtual int UnaryPredicate1D::operator()(Interface1D& inter);
virtual int BinaryPredicate1D::operator()(Interface1D& inter1, Interface1D& inter2);
virtual int StrokeShader::shade(Stroke& ioStroke) const;
virtual int UnaryFunction0D::operator()(Interface0DIterator& iter);
virtual int UnaryFunction1D::operator()(Interface1D& inter);

10 years agoAdded getExactTypeName() method.
Tamito Kajiyama [Fri, 20 Mar 2009 22:45:22 +0000 (22:45 +0000)]
Added getExactTypeName() method.

10 years agoFixed an uninitialized variable.
Tamito Kajiyama [Fri, 20 Mar 2009 22:44:04 +0000 (22:44 +0000)]
Fixed an uninitialized variable.

10 years agoImprovements in error handling at Python-C++ boundaries.
Tamito Kajiyama [Fri, 20 Mar 2009 22:42:59 +0000 (22:42 +0000)]
Improvements in error handling at Python-C++ boundaries.
Also exported the Operators.chain() function.

10 years agoImprovements in error handling at Python-C++ boundaries.
Tamito Kajiyama [Fri, 20 Mar 2009 22:41:27 +0000 (22:41 +0000)]
Improvements in error handling at Python-C++ boundaries.

10 years agoFixed incorrect argument checking.
Tamito Kajiyama [Sat, 14 Mar 2009 13:27:41 +0000 (13:27 +0000)]
Fixed incorrect argument checking.

10 years agoMade appropriate changes according to the fix in Revision 19287 concerning the Integr...
Tamito Kajiyama [Sat, 14 Mar 2009 13:23:35 +0000 (13:23 +0000)]
Made appropriate changes according to the fix in Revision 19287 concerning the IntegrationType type.

10 years agoFixed the subclassing of int to define the IntegrationType type.
Tamito Kajiyama [Sat, 14 Mar 2009 13:20:06 +0000 (13:20 +0000)]
Fixed the subclassing of int to define the IntegrationType type.
Also changed the type of integration type constants from int to IntegrationType.

10 years agoFixed StrokeVertex::setPoint() to accept a Blender Vector object as the argument.
Tamito Kajiyama [Sat, 14 Mar 2009 13:11:34 +0000 (13:11 +0000)]
Fixed StrokeVertex::setPoint() to accept a Blender Vector object as the argument.
Now this method accepts 2D coordinates in the following three forms:
a) Python list of 2 real numbers: setPoint([x, y])
b) Blender Vector of 2 elements: setPoint(Vector(x, y))
c) 2 real numbers: setPoint(x, y)

[The log of Revision 19283 had a wrong message...]

10 years agoFixed StrokeVertex::setPoint() to accept a Blender Vector object as the argument.
Tamito Kajiyama [Sat, 14 Mar 2009 13:06:09 +0000 (13:06 +0000)]
Fixed StrokeVertex::setPoint() to accept a Blender Vector object as the argument.
Now this method accepts 2D coordinates in the following three forms:
a) Python list of 2 real numbers: setPoint([x, y])
b) Blender Vector of 2 elements: setPoint(Vector(x, y))
c) 2 real numbers: setPoint(x, y)

10 years agoFixed memory leaks in passing vectors from Python to C++.
Tamito Kajiyama [Fri, 13 Mar 2009 19:27:00 +0000 (19:27 +0000)]
Fixed memory leaks in passing vectors from Python to C++.

10 years agoBetter error handling in the Python API.
Tamito Kajiyama [Fri, 13 Mar 2009 19:24:05 +0000 (19:24 +0000)]
Better error handling in the Python API.
Added error handling to prevent crashes even when errors have occurred in user-defined predicates, stroke shaders, and chaining iterators.

10 years agoFixed an immediate crash due to execution failure of a style module.
Tamito Kajiyama [Sun, 8 Mar 2009 12:02:23 +0000 (12:02 +0000)]
Fixed an immediate crash due to execution failure of a style module.

10 years agoFixed an issue regarding render layers. Now the Freestyle renderer builds a view...
Tamito Kajiyama [Mon, 2 Mar 2009 03:30:59 +0000 (03:30 +0000)]
Fixed an issue regarding render layers.  Now the Freestyle renderer builds a view map based on selected object layers in a render layer, instead of the global selection of object layers.  This allows, for example, to have two render layers, one for rendering solid faces in all object layers, and the other for rendering outlines of objects in selected object layers by Freestyle.  At the moment, the number of Freestyle-enabled render layers is restricted to one -- a better fix is in the future work.

10 years agorenamed app_blender/api.cpp FRS_freestyle.cpp
Maxime Curioni [Wed, 10 Dec 2008 22:13:23 +0000 (22:13 +0000)]
renamed app_blender/api.cpp FRS_freestyle.cpp

10 years agoimproved Freestyle IO formatting
Maxime Curioni [Wed, 10 Dec 2008 22:06:27 +0000 (22:06 +0000)]
improved Freestyle IO formatting

10 years agoremoved AppGLWidget and all related classes
Maxime Curioni [Wed, 10 Dec 2008 21:51:58 +0000 (21:51 +0000)]
removed AppGLWidget and all related classes
added an AppView class to transfer camera information from Blender to Freestyle
removed unused functions

10 years agowhen Freestyle would execute style modules, a copy of the Python script would end...
Maxime Curioni [Wed, 10 Dec 2008 18:36:56 +0000 (18:36 +0000)]
when Freestyle would execute style modules, a copy of the Python script would end up in the text editor and pollute the text editor file list. This is corrected: executed scripts do not leave trails behind.

10 years agoreplaced "Shape loading" message with "Importing triangular meshes into Blender"
Maxime Curioni [Wed, 10 Dec 2008 15:30:43 +0000 (15:30 +0000)]
replaced "Shape loading" message with "Importing triangular meshes into Blender"
handled case when scene is empty
made controller's view map as public variable

10 years agocorrected crash caused when enabling scene vectors
Maxime Curioni [Tue, 9 Dec 2008 17:14:34 +0000 (17:14 +0000)]
corrected crash caused when enabling scene vectors

10 years agocorrected problems using different filters: Freestyle pixels were being fetched outsi...
Maxime Curioni [Fri, 5 Dec 2008 11:03:16 +0000 (11:03 +0000)]
corrected problems using different filters: Freestyle pixels were being fetched outside of the render result rect. Corrected with a test to make sure that the used pixels are valid.

10 years agoReverted the changes (in revisions 17517-17519) for the antialiasing based on OpenGL...
Tamito Kajiyama [Thu, 4 Dec 2008 22:47:26 +0000 (22:47 +0000)]
Reverted the changes (in revisions 17517-17519) for the antialiasing based on OpenGL accumulation buffer.

10 years agofixed OSA and tile rendering problems
Maxime Curioni [Thu, 4 Dec 2008 10:57:02 +0000 (10:57 +0000)]
fixed OSA and tile rendering problems

10 years agoThe GL-based renderer was removed. Freestyle now uses Blender's internal renderer...
Maxime Curioni [Mon, 1 Dec 2008 21:30:44 +0000 (21:30 +0000)]
The GL-based renderer was removed. Freestyle now uses Blender's internal renderer to raster strokes.

The render generated from Freestyle's data is currently stored in the original scene's render structure ( as 'freestyle_render'): when the render database is generated, the scene's geometrical data is first imported into Freestyle and strokes are calculated. The generated strokes are used to create a Blender scene, rendered independently. The render result is used in the rendering loop.

The final rendering is performed the same way edge rendering is, in a function ('freestyle_enhance_add') operating on each individual render part. Freestyle strokes are only included if the toggle button "Freestyle" (in the 'Output' panel) is active and if the "Freestyle" render layer is also selected. Freestyle's panel appears when the toggle button 'Freestyle' is active.

IMPORTANT: as of now, rendering ONLY works when OSA is disabled and when Xparts = Yparts = 1. If these settings are not set, a bogus image will be created.

To make the render happen, many modifications had to be made:
- the Canvas::Draw and Operators::create methods no longer render strokes. They only generate shading and locational information.
- a BlenderStrokeRenderer class was added to turn Freestyle's strokes into a Blender scene. Basically, the scene consists of strokes in their projected image 2D coordinates and an orthographic camera centered in the middle of the corresponding canvas. The scene is rendered using vertex colors, in shadeless mode (therefore, no lamp is needed). BlenderStrokeRenderer uses the old GLTextureManager to load textures (as required by the StrokeRenderer class), even though stroke textures are probably not supported (not tested). After the scene is rendered, it is safely and automatically discarded.
- AppCanvas' code was greatly reduced to the bare minimum. The former AppCanvas would use an OpenGL-based back buffer and z buffer to determine the scene's color and depth information. In the future, this data will be determined from the corresponding render passes. Currently, the integration is not achieved so all style modules using depth/color information are sure to fail.
- before, Freestyle needed an OpenGL context to determine the camera's information and to compute the view map. As of now, the modelview and projection matrices are fully determined using data provided by Blender. This means both perspective and orthographic projections are supported. The AppGLWidget will very soon be removed completely.

10 years agoAdded changes to support Python's native iterator protocol in Stroke and StrokeVertex...
Tamito Kajiyama [Mon, 1 Dec 2008 11:14:33 +0000 (11:14 +0000)]
Added changes to support Python's native iterator protocol in Stroke and StrokeVertexIterator.
* Added a generic getName() method that allows subclasses to omit the method to return their class names.

* Added to BPy_StrokeVertexIterator_from_StrokeVertexIterator() a second argument to specify the direction (reversed or not) of the iterator to be created.

* Added support for Python's native iterator protocol.
* Added code to parse the optional argument of strokeVerticesBegin().

* Added support for Python's native iterator protocol.

* Fixed a null pointer reference.

* Added new method Stroke::strokeVerticeAt(i) that returns the i-th StrokeVertex of the Stroke.

10 years agoFixed memory leaks.
Tamito Kajiyama [Mon, 1 Dec 2008 10:49:06 +0000 (10:49 +0000)]
Fixed memory leaks.

10 years agoAdded changes for implementing antialiasing. The OSA settings for the internal
Tamito Kajiyama [Thu, 20 Nov 2008 20:42:38 +0000 (20:42 +0000)]
Added changes for implementing antialiasing.  The OSA settings for the internal
renderer are respected by the Freestyle renderer as well.

10 years agoRenamed arguments rad1 and rad2 in order to avoid name conflicts with symbols
Tamito Kajiyama [Thu, 20 Nov 2008 20:41:53 +0000 (20:41 +0000)]
Renamed arguments rad1 and rad2 in order to avoid name conflicts with symbols
defined in Microsoft SDKs/Windows/v6.1/include/dlgs.h.