Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2014-07-19 13:52:32 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2014-08-12 05:10:36 +0400
commit34c133a488bdd78a1bd5027e1dcc8c60da86d25a (patch)
tree6cc5822b6a0fc79b9d8ae0fdb75a3cebf6fa6080 /source/blender/freestyle/intern/stroke
parentc38e80d6322b942fd2a893f4f294a919ed6e6b99 (diff)
Freestyle: an improved workflow of line style shading nodes.
Removed the previous changes for passing a line style through the Controller, and revised the BlenderTextureShader to assign the shader node tree of a line style (if specified) to strokes. This way the assignment of shading nodes can be done through both the Freestyle GUI and Python scripting.
Diffstat (limited to 'source/blender/freestyle/intern/stroke')
-rw-r--r--source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp8
-rw-r--r--source/blender/freestyle/intern/stroke/BasicStrokeShaders.h15
-rw-r--r--source/blender/freestyle/intern/stroke/Stroke.cpp14
-rw-r--r--source/blender/freestyle/intern/stroke/Stroke.h41
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeLayer.cpp7
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeLayer.h6
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeRep.cpp9
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeRep.h14
-rw-r--r--source/blender/freestyle/intern/stroke/StyleModule.h2
9 files changed, 50 insertions, 66 deletions
diff --git a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
index e92913d097e..b7b5eb4162b 100644
--- a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
+++ b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp
@@ -451,7 +451,13 @@ int ColorNoiseShader::shade(Stroke& stroke) const
int BlenderTextureShader::shade(Stroke& stroke) const
{
- return stroke.setMTex(_mtex);
+ if (_mtex)
+ return stroke.setMTex(_mtex);
+ if (_nodeTree) {
+ stroke.setNodeTree(_nodeTree);
+ return 0;
+ }
+ return -1;
}
int StrokeTextureStepShader::shade(Stroke& stroke) const
diff --git a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h
index 9186d164e9b..6ac22c5b2d1 100644
--- a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h
+++ b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.h
@@ -36,7 +36,10 @@
#include "../geometry/Bezier.h"
#include "../geometry/Geom.h"
+extern "C" {
struct MTex;
+struct bNodeTree;
+}
using namespace std;
@@ -904,6 +907,7 @@ class BlenderTextureShader : public StrokeShader
{
private:
MTex *_mtex;
+ bNodeTree *_nodeTree;
public:
/*! Builds the shader.
@@ -913,6 +917,17 @@ public:
BlenderTextureShader(MTex *mtex) : StrokeShader()
{
_mtex = mtex;
+ _nodeTree = NULL;
+ }
+
+ /*! Builds the shader.
+ * \param nodetree
+ * A node tree (of new shading nodes) to define textures.
+ */
+ BlenderTextureShader(bNodeTree *nodetree) : StrokeShader()
+ {
+ _nodeTree = nodetree;
+ _mtex = NULL;
}
virtual string getName() const
diff --git a/source/blender/freestyle/intern/stroke/Stroke.cpp b/source/blender/freestyle/intern/stroke/Stroke.cpp
index 8900d19a102..863da069259 100644
--- a/source/blender/freestyle/intern/stroke/Stroke.cpp
+++ b/source/blender/freestyle/intern/stroke/Stroke.cpp
@@ -30,10 +30,7 @@
#include "StrokeAdvancedIterators.h"
#include "StrokeRenderer.h"
-#include "DNA_linestyle_types.h"
-
#include "BKE_global.h"
-#include "BKE_linestyle.h"
#include "BKE_node.h"
namespace Freestyle {
@@ -398,11 +395,10 @@ Stroke::Stroke()
_mediumType = OPAQUE_MEDIUM;
_textureId = 0;
_textureStep = 1.0;
- _lineStyle = NULL;
- _useShadingNodes = false;
for (int a = 0; a < MAX_MTEX; a++) {
_mtex[a] = NULL;
}
+ _nodeTree = NULL;
_tips = false;
}
@@ -421,8 +417,6 @@ Stroke::Stroke(const Stroke& iBrother)
_mediumType = iBrother._mediumType;
_textureId = iBrother._textureId;
_textureStep = iBrother._textureStep;
- _lineStyle = iBrother._lineStyle;
- _useShadingNodes = iBrother._useShadingNodes;
for (int a = 0; a < MAX_MTEX; a++) {
if (iBrother._mtex) {
_mtex[a] = iBrother._mtex[a];
@@ -431,6 +425,7 @@ Stroke::Stroke(const Stroke& iBrother)
_mtex[a] = NULL;
}
}
+ _nodeTree = iBrother._nodeTree;
_tips = iBrother._tips;
}
@@ -760,11 +755,6 @@ void Stroke::ScaleThickness(float iFactor)
}
}
-bool Stroke::hasTex() const
-{
- return BKE_linestyle_use_textures(_lineStyle, _useShadingNodes);
-}
-
void Stroke::Render(const StrokeRenderer *iRenderer)
{
StrokeRep rep(this);
diff --git a/source/blender/freestyle/intern/stroke/Stroke.h b/source/blender/freestyle/intern/stroke/Stroke.h
index 391fbc47e34..f919cd36f5c 100644
--- a/source/blender/freestyle/intern/stroke/Stroke.h
+++ b/source/blender/freestyle/intern/stroke/Stroke.h
@@ -46,7 +46,7 @@
extern "C" {
#include "DNA_material_types.h"
-struct FreestyleLineStyle;
+struct bNodeTree;
}
#ifndef MAX_MTEX
@@ -543,10 +543,9 @@ private:
MediumType _mediumType;
unsigned int _textureId;
MTex *_mtex[MAX_MTEX];
+ bNodeTree *_nodeTree;
bool _tips;
Vec2r _extremityOrientations[2]; // the orientations of the first and last extermity
- FreestyleLineStyle *_lineStyle;
- bool _useShadingNodes;
public:
/*! default constructor */
@@ -645,18 +644,6 @@ public:
return _mediumType;
}
- /*! Return the line style associated to this Stroke. */
- inline FreestyleLineStyle *getLineStyle()
- {
- return _lineStyle;
- }
-
- /*! Return true if the new shading nodes are used. */
- inline bool useShadingNodes()
- {
- return _useShadingNodes;
- }
-
/*! Returns the id of the texture used to simulate th marks system for this Stroke */
inline unsigned int getTextureId() {return _textureId;}
@@ -668,8 +655,17 @@ public:
return _mtex[idx];
}
+ /*! Return the shader node tree to define textures. */
+ inline bNodeTree *getNodeTree()
+ {
+ return _nodeTree;
+ }
+
/*! Returns true if this Stroke has textures assigned, false otherwise. */
- bool hasTex() const;
+ inline bool hasTex() const
+ {
+ return (_mtex && _mtex[0] != NULL) || _nodeTree;
+ }
/*! Returns true if this Stroke uses a texture with tips, false otherwise. */
inline bool hasTips() const
@@ -749,13 +745,6 @@ public:
/*! sets the 2D length of the Stroke. */
void setLength(float iLength);
- /*! sets the line style of the Stroke. */
- void setLineStyle(struct FreestyleLineStyle *iLineStyle, bool iUseShadingNodes)
- {
- _lineStyle = iLineStyle;
- _useShadingNodes = iUseShadingNodes;
- }
-
/*! sets the medium type that must be used for this Stroke. */
inline void setMediumType(MediumType iType)
{
@@ -786,6 +775,12 @@ public:
return -1; /* no free slots */
}
+ /*! assigns a node tree (of new shading nodes) to define textures. */
+ inline void setNodeTree(bNodeTree *iNodeTree)
+ {
+ _nodeTree = iNodeTree;
+ }
+
/*! sets the flag telling whether this stroke is using a texture with tips or not. */
inline void setTips(bool iTips)
{
diff --git a/source/blender/freestyle/intern/stroke/StrokeLayer.cpp b/source/blender/freestyle/intern/stroke/StrokeLayer.cpp
index 6765bf1b665..67552d6ebf2 100644
--- a/source/blender/freestyle/intern/stroke/StrokeLayer.cpp
+++ b/source/blender/freestyle/intern/stroke/StrokeLayer.cpp
@@ -36,13 +36,6 @@ StrokeLayer::~StrokeLayer()
clear();
}
-void StrokeLayer::setLineStyle(struct FreestyleLineStyle *iLineStyle, bool iUseShadingNodes)
-{
- for (StrokeLayer::stroke_container::iterator s = _strokes.begin(), send = _strokes.end(); s != send; ++s) {
- (*s)->setLineStyle(iLineStyle, iUseShadingNodes);
- }
-}
-
void StrokeLayer::ScaleThickness(float iFactor)
{
for (StrokeLayer::stroke_container::iterator s = _strokes.begin(), send = _strokes.end(); s != send; ++s) {
diff --git a/source/blender/freestyle/intern/stroke/StrokeLayer.h b/source/blender/freestyle/intern/stroke/StrokeLayer.h
index bef7a2aca43..91292e237d6 100644
--- a/source/blender/freestyle/intern/stroke/StrokeLayer.h
+++ b/source/blender/freestyle/intern/stroke/StrokeLayer.h
@@ -34,10 +34,6 @@
#include "MEM_guardedalloc.h"
#endif
-extern "C" {
-struct FreestyleLineStyle;
-}
-
namespace Freestyle {
class Stroke;
@@ -105,8 +101,6 @@ public:
_strokes.push_back(iStroke);
}
- void setLineStyle(struct FreestyleLineStyle *iLineStyle, bool iUseShadingNodes);
-
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:StrokeLayer")
#endif
diff --git a/source/blender/freestyle/intern/stroke/StrokeRep.cpp b/source/blender/freestyle/intern/stroke/StrokeRep.cpp
index bdc21913f14..f4ac6f70fbb 100644
--- a/source/blender/freestyle/intern/stroke/StrokeRep.cpp
+++ b/source/blender/freestyle/intern/stroke/StrokeRep.cpp
@@ -705,8 +705,7 @@ StrokeRep::StrokeRep()
{
_stroke = 0;
_strokeType = Stroke::OPAQUE_MEDIUM;
- _lineStyle = NULL;
- _useShadingNodes = false;
+ _nodeTree = NULL;
_hasTex = false;
_textureStep = 1.0;
for (int a = 0; a < MAX_MTEX; a++) {
@@ -728,8 +727,7 @@ StrokeRep::StrokeRep(Stroke *iStroke)
{
_stroke = iStroke;
_strokeType = iStroke->getMediumType();
- _lineStyle = iStroke->getLineStyle();
- _useShadingNodes = iStroke->useShadingNodes();
+ _nodeTree = iStroke->getNodeTree();
_hasTex = iStroke->hasTex();
_textureId = iStroke->getTextureId();
_textureStep = iStroke->getTextureStep();
@@ -764,8 +762,7 @@ StrokeRep::StrokeRep(const StrokeRep& iBrother)
_strokeType = iBrother._strokeType;
_textureId = iBrother._textureId;
_textureStep = iBrother._textureStep;
- _lineStyle = iBrother._lineStyle;
- _useShadingNodes = iBrother._useShadingNodes;
+ _nodeTree = iBrother._nodeTree;
_hasTex = iBrother._hasTex;
for (int a = 0; a < MAX_MTEX; a++) {
if (iBrother._mtex[a]) {
diff --git a/source/blender/freestyle/intern/stroke/StrokeRep.h b/source/blender/freestyle/intern/stroke/StrokeRep.h
index a62fa4bdb9e..ba042eb496d 100644
--- a/source/blender/freestyle/intern/stroke/StrokeRep.h
+++ b/source/blender/freestyle/intern/stroke/StrokeRep.h
@@ -38,7 +38,7 @@
extern "C" {
#include "DNA_material_types.h" // for MAX_MTEX
-struct FreestyleLineStyle;
+struct bNodeTree;
}
namespace Freestyle {
@@ -186,9 +186,8 @@ protected:
unsigned int _textureId;
float _textureStep;
MTex *_mtex[MAX_MTEX];
+ bNodeTree *_nodeTree;
Material *_material;
- FreestyleLineStyle *_lineStyle;
- bool _useShadingNodes;
bool _hasTex;
// float _averageTextureAlpha;
@@ -226,14 +225,9 @@ public:
return _material;
}
- inline FreestyleLineStyle *getLineStyle() const
+ inline bNodeTree *getNodeTree() const
{
- return _lineStyle;
- }
-
- inline bool useShadingNodes() const
- {
- return _useShadingNodes;
+ return _nodeTree;
}
inline bool hasTex() const
diff --git a/source/blender/freestyle/intern/stroke/StyleModule.h b/source/blender/freestyle/intern/stroke/StyleModule.h
index 86127e7a592..f1d96283f90 100644
--- a/source/blender/freestyle/intern/stroke/StyleModule.h
+++ b/source/blender/freestyle/intern/stroke/StyleModule.h
@@ -62,7 +62,7 @@ public:
virtual ~StyleModule() {}
- virtual StrokeLayer *execute()
+ StrokeLayer *execute()
{
if (!_inter) {
cerr << "Error: no interpreter was found to execute the script" << endl;