From 1ddb8e238e1239998c810fca5733641005b0964f Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Fri, 18 Jul 2014 21:40:11 +0900 Subject: Freestyle: Keep a reference of the line style in Stroke rather than in StrokeRep. --- .../intern/blender_interface/BlenderStyleModule.h | 2 +- source/blender/freestyle/intern/stroke/Stroke.cpp | 7 ------- source/blender/freestyle/intern/stroke/Stroke.h | 14 +++++++++++++- source/blender/freestyle/intern/stroke/StrokeLayer.cpp | 8 ++++---- source/blender/freestyle/intern/stroke/StrokeLayer.h | 3 ++- source/blender/freestyle/intern/stroke/StrokeRep.cpp | 2 +- source/blender/freestyle/intern/stroke/StrokeRep.h | 5 ----- 7 files changed, 21 insertions(+), 20 deletions(-) (limited to 'source/blender/freestyle') diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStyleModule.h b/source/blender/freestyle/intern/blender_interface/BlenderStyleModule.h index cff3593b761..ad656fdc3f7 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderStyleModule.h +++ b/source/blender/freestyle/intern/blender_interface/BlenderStyleModule.h @@ -57,7 +57,7 @@ public: { StrokeLayer *sl = StyleModule::execute(); - sl->SetLineStyle(_linestyle); + sl->setLineStyle(_linestyle); return sl; } diff --git a/source/blender/freestyle/intern/stroke/Stroke.cpp b/source/blender/freestyle/intern/stroke/Stroke.cpp index 158ceea93a3..c85295e72bf 100644 --- a/source/blender/freestyle/intern/stroke/Stroke.cpp +++ b/source/blender/freestyle/intern/stroke/Stroke.cpp @@ -774,13 +774,6 @@ void Stroke::ScaleThickness(float iFactor) } } -void Stroke::SetLineStyle(struct FreestyleLineStyle *iLineStyle) -{ - if (!_rep) - _rep = new StrokeRep(this); - _rep->setLineStyle(iLineStyle); -} - void Stroke::Render(const StrokeRenderer *iRenderer) { if (!_rep) diff --git a/source/blender/freestyle/intern/stroke/Stroke.h b/source/blender/freestyle/intern/stroke/Stroke.h index e18e176baba..d68a5938e98 100644 --- a/source/blender/freestyle/intern/stroke/Stroke.h +++ b/source/blender/freestyle/intern/stroke/Stroke.h @@ -546,6 +546,7 @@ private: bool _tips; Vec2r _extremityOrientations[2]; // the orientations of the first and last extermity StrokeRep *_rep; + FreestyleLineStyle *_lineStyle; public: /*! default constructor */ @@ -625,7 +626,6 @@ public: /* Render method */ void ScaleThickness(float iFactor); - void SetLineStyle(struct FreestyleLineStyle *iLineStyle); void Render(const StrokeRenderer *iRenderer); void RenderBasic(const StrokeRenderer *iRenderer); @@ -645,6 +645,12 @@ public: return _mediumType; } + /*! Return the line style associated to this Stroke. */ + inline FreestyleLineStyle *getLineStyle() + { + return _lineStyle; + } + /*! Returns the id of the texture used to simulate th marks system for this Stroke */ inline unsigned int getTextureId() {return _textureId;} @@ -740,6 +746,12 @@ public: /*! sets the 2D length of the Stroke. */ void setLength(float iLength); + /*! sets the line style of the Stroke. */ + void setLineStyle(struct FreestyleLineStyle *iLineStyle) + { + _lineStyle = iLineStyle; + } + /*! sets the medium type that must be used for this Stroke. */ inline void setMediumType(MediumType iType) { diff --git a/source/blender/freestyle/intern/stroke/StrokeLayer.cpp b/source/blender/freestyle/intern/stroke/StrokeLayer.cpp index 14251162168..ae8425625f2 100644 --- a/source/blender/freestyle/intern/stroke/StrokeLayer.cpp +++ b/source/blender/freestyle/intern/stroke/StrokeLayer.cpp @@ -36,17 +36,17 @@ StrokeLayer::~StrokeLayer() clear(); } -void StrokeLayer::ScaleThickness(float iFactor) +void StrokeLayer::setLineStyle(struct FreestyleLineStyle *iLineStyle) { for (StrokeLayer::stroke_container::iterator s = _strokes.begin(), send = _strokes.end(); s != send; ++s) { - (*s)->ScaleThickness(iFactor); + (*s)->setLineStyle(iLineStyle); } } -void StrokeLayer::SetLineStyle(struct FreestyleLineStyle *iLineStyle) +void StrokeLayer::ScaleThickness(float iFactor) { for (StrokeLayer::stroke_container::iterator s = _strokes.begin(), send = _strokes.end(); s != send; ++s) { - (*s)->SetLineStyle(iLineStyle); + (*s)->ScaleThickness(iFactor); } } diff --git a/source/blender/freestyle/intern/stroke/StrokeLayer.h b/source/blender/freestyle/intern/stroke/StrokeLayer.h index 93eca3be8c7..31fe368d931 100644 --- a/source/blender/freestyle/intern/stroke/StrokeLayer.h +++ b/source/blender/freestyle/intern/stroke/StrokeLayer.h @@ -67,7 +67,6 @@ public: /*! Render method */ void ScaleThickness(float iFactor); - void SetLineStyle(struct FreestyleLineStyle *iLineStyle); void Render(const StrokeRenderer *iRenderer); void RenderBasic(const StrokeRenderer *iRenderer); @@ -106,6 +105,8 @@ public: _strokes.push_back(iStroke); } + void setLineStyle(struct FreestyleLineStyle *iLineStyle); + #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 25e242b9dbe..04087693e3b 100644 --- a/source/blender/freestyle/intern/stroke/StrokeRep.cpp +++ b/source/blender/freestyle/intern/stroke/StrokeRep.cpp @@ -725,7 +725,7 @@ StrokeRep::StrokeRep(Stroke *iStroke) { _stroke = iStroke; _strokeType = iStroke->getMediumType(); - _lineStyle = NULL; + _lineStyle = iStroke->getLineStyle(); _textureId = iStroke->getTextureId(); _textureStep = iStroke->getTextureStep(); for (int a = 0; a < MAX_MTEX; a++) { diff --git a/source/blender/freestyle/intern/stroke/StrokeRep.h b/source/blender/freestyle/intern/stroke/StrokeRep.h index dad36cd01ed..cf07e7aa108 100644 --- a/source/blender/freestyle/intern/stroke/StrokeRep.h +++ b/source/blender/freestyle/intern/stroke/StrokeRep.h @@ -265,11 +265,6 @@ public: _mtex[idx] = mtex_ptr; }*/ - inline void setLineStyle(FreestyleLineStyle *iLineStyle) - { - _lineStyle = iLineStyle; - } - #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:StrokeRep") #endif -- cgit v1.2.3