Commit Graph

12418 Commits

Author SHA1 Message Date
2bcb57f29b Second attempt for properly releasing temporary objects and their data
blocks in BlenderStrokeRenderer::~BlenderStrokeRenderer().
2009-07-22 23:27:10 +00:00
34744276d4 Made changes for releasing temporary objects and their data blocks
in BlenderStrokeRenderer::~BlenderStrokeRenderer().
2009-07-22 00:01:34 +00:00
f19ae70820 Fixed a refcount bug concerning ChainPredicateIterator. 2009-07-21 19:44:15 +00:00
5fed0560d9 * Introspection-based automatic type conversion from a generic C++ object
to a specific Python object.  The conversion takes place in the following
places.
- 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
2009-07-19 23:17:30 +00:00
1cb1d0e6e9 Added a missing wrapper for AdjacencyIterator::isIncoming(). 2009-07-19 23:03:26 +00:00
770267437b Fixed uninitialized pointers in ViewVertex instances returned by the
castToViewVertex method.
2009-07-19 23:01:25 +00:00
47fddb50c5 Fixed uninitialized pointers in Interface0DIterator instances returned by
the castToInterface0DIterator method.
2009-07-19 16:37:55 +00:00
ef11c4e8e7 Fixed a bug that the parameter panel did not correctly work when
a new file was created or an existing file was loaded.
2009-07-18 18:33:07 +00:00
Maxime Curioni
e7f3a3d93a Simplified modelview matrix copy (take 2) 2009-04-12 07:12:59 +00:00
Maxime Curioni
452593a053 Simplified modelview matrix copy 2009-04-12 07:02:03 +00:00
Maxime Curioni
f9cc722e57 Corrected memory deallocation error on exit 2009-04-08 23:03:46 +00:00
Maxime Curioni
7e1d0b5003 Corrected the problem of the view moving after a Freestyle render, when positioned at the camera location 2009-04-08 21:44:38 +00:00
Maxime Curioni
8c8579d911 Made the calculation of the number of available style modules more robust 2009-04-08 20:19:20 +00:00
Maxime Curioni
997624c7dd Corrected crash when calculating number of available style modules 2009-04-08 17:32:56 +00:00
Maxime Curioni
5dd39e6517 SUMMARY:
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

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

LIMITATIONS
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.
2009-04-07 18:38:23 +00:00
6225d2d3f9 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).
2009-04-05 16:20:41 +00:00
2f5e1969ed Improvements on error handling in the Python API. 2009-04-04 15:26:12 +00:00
bff81e3394 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.
2009-04-04 14:50:54 +00:00
acfd7c82ab 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.
2009-04-03 20:03:09 +00:00
5926ad2db2 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.
2009-04-02 19:28:14 +00:00
044c2b1fc4 Added getExactTypeName() method. 2009-04-01 01:21:11 +00:00
67e4d7dc63 Improvements on error handling in the Python API. 2009-03-31 22:45:11 +00:00
3c60dd404e * fixed uninitialized variables.
* fixed a bug that was introduced in the last commit.
2009-03-30 19:25:27 +00:00
a377b74638 Improvements on error handling in the Python API. 2009-03-29 21:50:10 +00:00
fbd92e985e * improved error handling in CurvePointIterator constructor.
* changed CurvePointIterator::getObject() according to the changes
in revision 19456.
2009-03-29 21:05:03 +00:00
ded03e34bf * 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.
2009-03-29 21:00:26 +00:00
6dfcbf166b Fixed a typo in the last commit. 2009-03-29 18:46:17 +00:00
68e088f1cf Improvements on error handling in the Python API. 2009-03-29 17:44:14 +00:00
Maxime Curioni
d79ddebaae 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)
2009-03-22 16:25:14 +00:00
f86309d672 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.
2009-03-21 12:09:58 +00:00
Maxime Curioni
f520fb2426 Corrected stroke/Operators.cpp to compile without warnings
Cleaned up comments
2009-03-21 04:51:51 +00:00
c1611c346f Fixed editing errors in the last commit... 2009-03-20 23:19:47 +00:00
a068212445 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);
2009-03-20 22:55:07 +00:00
ac0918a1be Added getExactTypeName() method. 2009-03-20 22:45:22 +00:00
c5fe802ec8 Fixed an uninitialized variable. 2009-03-20 22:44:04 +00:00
85291f0fea Improvements in error handling at Python-C++ boundaries.
Also exported the Operators.chain() function.
2009-03-20 22:42:59 +00:00
0c7e5323e8 Improvements in error handling at Python-C++ boundaries. 2009-03-20 22:41:27 +00:00
6ba34d18b5 Fixed incorrect argument checking. 2009-03-14 13:27:41 +00:00
f38183d6b4 Fixed the subclassing of int to define the IntegrationType type.
Also changed the type of integration type constants from int to IntegrationType.
2009-03-14 13:20:06 +00:00
52e289ee3b 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...]
2009-03-14 13:11:34 +00:00
c14e91590e 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)
2009-03-14 13:06:09 +00:00
c8ac7723d6 Fixed memory leaks in passing vectors from Python to C++. 2009-03-13 19:27:00 +00:00
2fbcd6c4bd 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.
2009-03-13 19:24:05 +00:00
838234e5ea Fixed an immediate crash due to execution failure of a style module. 2009-03-08 12:02:23 +00:00
cd202bc3b6 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. 2009-03-02 03:30:59 +00:00
Maxime Curioni
20496ca644 renamed app_blender/api.cpp FRS_freestyle.cpp 2008-12-10 22:13:23 +00:00
Maxime Curioni
2f460b448b improved Freestyle IO formatting 2008-12-10 22:06:27 +00:00
Maxime Curioni
d15321082e removed AppGLWidget and all related classes
added an AppView class to transfer camera information from Blender to Freestyle
removed unused functions
2008-12-10 21:51:58 +00:00
Maxime Curioni
8b3e4bc069 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. 2008-12-10 18:36:56 +00:00
Maxime Curioni
eaae4090c1 replaced "Shape loading" message with "Importing triangular meshes into Blender"
handled case when scene is empty
made controller's view map as public variable
2008-12-10 15:30:43 +00:00