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 10:38:56 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2014-08-12 05:10:35 +0400
commitc38e80d6322b942fd2a893f4f294a919ed6e6b99 (patch)
tree67470e7670d5975085a5a211a3c5aab9cef4aa51 /source/blender/freestyle/intern/stroke
parenta2a2d4679ae28dbc9f6bed1c8663cea9ccb71176 (diff)
WIP commit just for a record of a working snapshot of code revisions for node-based textured strokes.
Diffstat (limited to 'source/blender/freestyle/intern/stroke')
-rw-r--r--source/blender/freestyle/intern/stroke/Stroke.cpp45
-rw-r--r--source/blender/freestyle/intern/stroke/Stroke.h16
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeLayer.cpp4
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeLayer.h2
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeRep.cpp9
-rw-r--r--source/blender/freestyle/intern/stroke/StrokeRep.h12
6 files changed, 50 insertions, 38 deletions
diff --git a/source/blender/freestyle/intern/stroke/Stroke.cpp b/source/blender/freestyle/intern/stroke/Stroke.cpp
index c85295e72bf..8900d19a102 100644
--- a/source/blender/freestyle/intern/stroke/Stroke.cpp
+++ b/source/blender/freestyle/intern/stroke/Stroke.cpp
@@ -30,7 +30,11 @@
#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 {
@@ -394,11 +398,12 @@ 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;
}
_tips = false;
- _rep = NULL;
}
Stroke::Stroke(const Stroke& iBrother)
@@ -416,6 +421,8 @@ 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];
@@ -425,10 +432,6 @@ Stroke::Stroke(const Stroke& iBrother)
}
}
_tips = iBrother._tips;
- if (iBrother._rep)
- _rep = new StrokeRep(*(iBrother._rep));
- else
- _rep = NULL;
}
Stroke::~Stroke()
@@ -441,10 +444,6 @@ Stroke::~Stroke()
}
_ViewEdges.clear();
- if (_rep) {
- delete _rep;
- _rep = NULL;
- }
}
Stroke& Stroke::operator=(const Stroke& iBrother)
@@ -462,10 +461,6 @@ Stroke& Stroke::operator=(const Stroke& iBrother)
_id = iBrother._id;
_ViewEdges = iBrother._ViewEdges;
_sampling = iBrother._sampling;
- if (_rep)
- delete _rep;
- if (iBrother._rep)
- _rep = new StrokeRep(*(iBrother._rep));
return *this;
}
@@ -601,11 +596,6 @@ int Stroke::Resample(int iNPoints)
_Vertices = newVertices;
newVertices.clear();
- if (_rep) {
- delete _rep;
- _rep = new StrokeRep(this);
- }
-
return 0;
}
@@ -660,10 +650,6 @@ int Stroke::Resample(float iSampling)
_Vertices = newVertices;
newVertices.clear();
- if (_rep) {
- delete _rep;
- _rep = new StrokeRep(this);
- }
return 0;
}
@@ -774,18 +760,21 @@ void Stroke::ScaleThickness(float iFactor)
}
}
+bool Stroke::hasTex() const
+{
+ return BKE_linestyle_use_textures(_lineStyle, _useShadingNodes);
+}
+
void Stroke::Render(const StrokeRenderer *iRenderer)
{
- if (!_rep)
- _rep = new StrokeRep(this);
- iRenderer->RenderStrokeRep(_rep);
+ StrokeRep rep(this);
+ iRenderer->RenderStrokeRep(&rep);
}
void Stroke::RenderBasic(const StrokeRenderer *iRenderer)
{
- if (!_rep)
- _rep = new StrokeRep(this);
- iRenderer->RenderStrokeRepBasic(_rep);
+ StrokeRep rep(this);
+ iRenderer->RenderStrokeRepBasic(&rep);
}
Stroke::vertex_iterator Stroke::vertices_begin(float sampling)
diff --git a/source/blender/freestyle/intern/stroke/Stroke.h b/source/blender/freestyle/intern/stroke/Stroke.h
index d68a5938e98..391fbc47e34 100644
--- a/source/blender/freestyle/intern/stroke/Stroke.h
+++ b/source/blender/freestyle/intern/stroke/Stroke.h
@@ -545,8 +545,8 @@ private:
MTex *_mtex[MAX_MTEX];
bool _tips;
Vec2r _extremityOrientations[2]; // the orientations of the first and last extermity
- StrokeRep *_rep;
FreestyleLineStyle *_lineStyle;
+ bool _useShadingNodes;
public:
/*! default constructor */
@@ -651,6 +651,12 @@ public:
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;}
@@ -663,10 +669,7 @@ public:
}
/*! Returns true if this Stroke has textures assigned, false otherwise. */
- inline bool hasTex() const
- {
- return _mtex[0] != NULL;
- }
+ bool hasTex() const;
/*! Returns true if this Stroke uses a texture with tips, false otherwise. */
inline bool hasTips() const
@@ -747,9 +750,10 @@ public:
void setLength(float iLength);
/*! sets the line style of the Stroke. */
- void setLineStyle(struct FreestyleLineStyle *iLineStyle)
+ void setLineStyle(struct FreestyleLineStyle *iLineStyle, bool iUseShadingNodes)
{
_lineStyle = iLineStyle;
+ _useShadingNodes = iUseShadingNodes;
}
/*! sets the medium type that must be used for this Stroke. */
diff --git a/source/blender/freestyle/intern/stroke/StrokeLayer.cpp b/source/blender/freestyle/intern/stroke/StrokeLayer.cpp
index ae8425625f2..6765bf1b665 100644
--- a/source/blender/freestyle/intern/stroke/StrokeLayer.cpp
+++ b/source/blender/freestyle/intern/stroke/StrokeLayer.cpp
@@ -36,10 +36,10 @@ StrokeLayer::~StrokeLayer()
clear();
}
-void StrokeLayer::setLineStyle(struct FreestyleLineStyle *iLineStyle)
+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);
+ (*s)->setLineStyle(iLineStyle, iUseShadingNodes);
}
}
diff --git a/source/blender/freestyle/intern/stroke/StrokeLayer.h b/source/blender/freestyle/intern/stroke/StrokeLayer.h
index 31fe368d931..bef7a2aca43 100644
--- a/source/blender/freestyle/intern/stroke/StrokeLayer.h
+++ b/source/blender/freestyle/intern/stroke/StrokeLayer.h
@@ -105,7 +105,7 @@ public:
_strokes.push_back(iStroke);
}
- void setLineStyle(struct FreestyleLineStyle *iLineStyle);
+ void setLineStyle(struct FreestyleLineStyle *iLineStyle, bool iUseShadingNodes);
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:StrokeLayer")
diff --git a/source/blender/freestyle/intern/stroke/StrokeRep.cpp b/source/blender/freestyle/intern/stroke/StrokeRep.cpp
index 04087693e3b..bdc21913f14 100644
--- a/source/blender/freestyle/intern/stroke/StrokeRep.cpp
+++ b/source/blender/freestyle/intern/stroke/StrokeRep.cpp
@@ -516,6 +516,7 @@ void Strip::setVertexColor (const vector<StrokeVertex *>& iStrokeVertices)
void Strip::computeTexCoord (const vector<StrokeVertex *>& iStrokeVertices, float texStep)
{
+ cout << "Strip::computeTexCoord texStep " << texStep << endl;
vector<StrokeVertex *>::const_iterator v, vend;
StrokeVertex *sv;
int i = 0;
@@ -705,6 +706,8 @@ StrokeRep::StrokeRep()
_stroke = 0;
_strokeType = Stroke::OPAQUE_MEDIUM;
_lineStyle = NULL;
+ _useShadingNodes = false;
+ _hasTex = false;
_textureStep = 1.0;
for (int a = 0; a < MAX_MTEX; a++) {
_mtex[a] = NULL;
@@ -726,6 +729,8 @@ StrokeRep::StrokeRep(Stroke *iStroke)
_stroke = iStroke;
_strokeType = iStroke->getMediumType();
_lineStyle = iStroke->getLineStyle();
+ _useShadingNodes = iStroke->useShadingNodes();
+ _hasTex = iStroke->hasTex();
_textureId = iStroke->getTextureId();
_textureStep = iStroke->getTextureStep();
for (int a = 0; a < MAX_MTEX; a++) {
@@ -760,6 +765,8 @@ StrokeRep::StrokeRep(const StrokeRep& iBrother)
_textureId = iBrother._textureId;
_textureStep = iBrother._textureStep;
_lineStyle = iBrother._lineStyle;
+ _useShadingNodes = iBrother._useShadingNodes;
+ _hasTex = iBrother._hasTex;
for (int a = 0; a < MAX_MTEX; a++) {
if (iBrother._mtex[a]) {
_mtex[a] = iBrother._mtex[a];
@@ -811,7 +818,7 @@ void StrokeRep::create()
end = true;
}
if ((!strip.empty()) && (strip.size() > 1)) {
- _strips.push_back(new Strip(strip, _stroke->hasTex(), first, end, _textureStep));
+ _strips.push_back(new Strip(strip, _hasTex, first, end, _textureStep));
strip.clear();
}
first = false;
diff --git a/source/blender/freestyle/intern/stroke/StrokeRep.h b/source/blender/freestyle/intern/stroke/StrokeRep.h
index cf07e7aa108..a62fa4bdb9e 100644
--- a/source/blender/freestyle/intern/stroke/StrokeRep.h
+++ b/source/blender/freestyle/intern/stroke/StrokeRep.h
@@ -188,6 +188,8 @@ protected:
MTex *_mtex[MAX_MTEX];
Material *_material;
FreestyleLineStyle *_lineStyle;
+ bool _useShadingNodes;
+ bool _hasTex;
// float _averageTextureAlpha;
@@ -229,6 +231,16 @@ public:
return _lineStyle;
}
+ inline bool useShadingNodes() const
+ {
+ return _useShadingNodes;
+ }
+
+ inline bool hasTex() const
+ {
+ return _hasTex;
+ }
+
inline vector<Strip*>& getStrips()
{
return _strips;