[Bf-blender-cvs] [1ddb8e2] master: Freestyle: Keep a reference of the line style in Stroke rather than in StrokeRep.

Tamito Kajiyama noreply at git.blender.org
Tue Aug 12 03:17:41 CEST 2014


Commit: 1ddb8e238e1239998c810fca5733641005b0964f
Author: Tamito Kajiyama
Date:   Fri Jul 18 21:40:11 2014 +0900
Branches: master
https://developer.blender.org/rB1ddb8e238e1239998c810fca5733641005b0964f

Freestyle: Keep a reference of the line style in Stroke rather than in StrokeRep.

===================================================================

M	source/blender/freestyle/intern/blender_interface/BlenderStyleModule.h
M	source/blender/freestyle/intern/stroke/Stroke.cpp
M	source/blender/freestyle/intern/stroke/Stroke.h
M	source/blender/freestyle/intern/stroke/StrokeLayer.cpp
M	source/blender/freestyle/intern/stroke/StrokeLayer.h
M	source/blender/freestyle/intern/stroke/StrokeRep.cpp
M	source/blender/freestyle/intern/stroke/StrokeRep.h

===================================================================

diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStyleModule.h b/source/blender/freestyle/intern/blender_interface/BlenderStyleModule.h
index cff3593..ad656fd 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 158ceea..c85295e 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 e18e176..d68a593 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 1425116..ae84256 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 93eca3b..31fe368 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 25e242b..0408769 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 dad36cd..cf07e7a 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




More information about the Bf-blender-cvs mailing list