[Bf-blender-cvs] [160c658] master: Freestyle: minor optimization for space in the FEdgeXDetector.

Tamito Kajiyama noreply at git.blender.org
Mon Jul 20 01:11:56 CEST 2015


Commit: 160c65845dc52b2c705b1ead6e260a399fdccadb
Author: Tamito Kajiyama
Date:   Wed Jul 30 17:08:31 2014 +0900
Branches: master
https://developer.blender.org/rB160c65845dc52b2c705b1ead6e260a399fdccadb

Freestyle: minor optimization for space in the FEdgeXDetector.

Member variables and auto variables were changed from real (double) to float
in most part of the FEdgeXDetector (except for curvature computations).

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

M	source/blender/freestyle/intern/application/Controller.cpp
M	source/blender/freestyle/intern/application/Controller.h
M	source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp
M	source/blender/freestyle/intern/view_map/FEdgeXDetector.h

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

diff --git a/source/blender/freestyle/intern/application/Controller.cpp b/source/blender/freestyle/intern/application/Controller.cpp
index 6a24a47..e7eb25f 100644
--- a/source/blender/freestyle/intern/application/Controller.cpp
+++ b/source/blender/freestyle/intern/application/Controller.cpp
@@ -469,7 +469,7 @@ void Controller::ComputeViewMap()
 	// Restore the context of view:
 	// we need to perform all these operations while the 
 	// 3D context is on.
-	Vec3r vp(freestyle_viewpoint[0], freestyle_viewpoint[1], freestyle_viewpoint[2]);
+	Vec3f vp(freestyle_viewpoint[0], freestyle_viewpoint[1], freestyle_viewpoint[2]);
 
 #if 0
 	if (G.debug & G_DEBUG_FREESTYLE) {
diff --git a/source/blender/freestyle/intern/application/Controller.h b/source/blender/freestyle/intern/application/Controller.h
index a09964a..646c74f 100644
--- a/source/blender/freestyle/intern/application/Controller.h
+++ b/source/blender/freestyle/intern/application/Controller.h
@@ -136,12 +136,12 @@ public:
 
 	void setComputeSteerableViewMapFlag(bool iBool);
 	bool getComputeSteerableViewMapFlag() const;
-	void setCreaseAngle(real angle) {_creaseAngle = angle;}
-	real getCreaseAngle() const {return _creaseAngle;}
-	void setSphereRadius(real s) {_sphereRadius = s;}
-	real getSphereRadius() const {return _sphereRadius;}
-	void setSuggestiveContourKrDerivativeEpsilon(real dkr) {_suggestiveContourKrDerivativeEpsilon = dkr;}
-	real getSuggestiveContourKrDerivativeEpsilon() const {return _suggestiveContourKrDerivativeEpsilon;}
+	void setCreaseAngle(float angle) {_creaseAngle = angle;}
+	float getCreaseAngle() const {return _creaseAngle;}
+	void setSphereRadius(float s) {_sphereRadius = s;}
+	float getSphereRadius() const {return _sphereRadius;}
+	void setSuggestiveContourKrDerivativeEpsilon(float dkr) {_suggestiveContourKrDerivativeEpsilon = dkr;}
+	float getSuggestiveContourKrDerivativeEpsilon() const {return _suggestiveContourKrDerivativeEpsilon;}
 
 	void setModelsDir(const string& dir);
 	string getModelsDir() const;
@@ -243,9 +243,9 @@ private:
 	bool _ComputeRidges;
 	bool _ComputeSuggestive;
 	bool _ComputeMaterialBoundaries;
-	real _creaseAngle;
-	real _sphereRadius;
-	real _suggestiveContourKrDerivativeEpsilon;
+	float _creaseAngle;
+	float _sphereRadius;
+	float _suggestiveContourKrDerivativeEpsilon;
 
 	bool _ComputeSteerableViewMap;
 
diff --git a/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp b/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp
index f2aeee0..85c6390 100644
--- a/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp
+++ b/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp
@@ -148,16 +148,16 @@ void FEdgeXDetector::preProcessShape(WXShape *iWShape)
 
 void FEdgeXDetector::preProcessFace(WXFace *iFace)
 {
-	Vec3r firstPoint = iFace->GetVertex(0)->GetVertex();
-	Vec3r N = iFace->GetNormal();
+	Vec3f firstPoint = iFace->GetVertex(0)->GetVertex();
+	Vec3f N = iFace->GetNormal();
 
 	// Compute the dot product between V (=_Viewpoint - firstPoint) and N:
-	Vec3r V;
+	Vec3f V;
 	if (_orthographicProjection) {
-		V = Vec3r(0.0, 0.0, _Viewpoint.z() - firstPoint.z());
+		V = Vec3f(0.0f, 0.0f, _Viewpoint.z() - firstPoint.z());
 	}
 	else {
-		V = Vec3r(_Viewpoint - firstPoint);
+		V = Vec3f(_Viewpoint - firstPoint);
 	}
 	N.normalize();
 	V.normalize();
@@ -168,7 +168,7 @@ void FEdgeXDetector::preProcessFace(WXFace *iFace)
 		iFace->setZ(iFace->center().z() - _Viewpoint.z());
 	}
 	else {
-		Vec3r dist_vec(iFace->center() - _Viewpoint);
+		Vec3f dist_vec(iFace->center() - _Viewpoint);
 		iFace->setZ(dist_vec.norm());
 	}
 }
@@ -273,33 +273,33 @@ void FEdgeXDetector::processSilhouetteShape(WXShape *iWShape)
 void FEdgeXDetector::ProcessSilhouetteFace(WXFace *iFace)
 {
 	// SILHOUETTE LAYER
-	Vec3r normal;
+	Vec3f normal;
 	// Compute the dot products between View direction and N at each vertex of the face:
-	Vec3r point;
+	Vec3f point;
 	int closestPointId = 0;
-	real dist, minDist = FLT_MAX;
+	float dist, minDist = FLT_MAX;
 	int numVertices = iFace->numberOfVertices();
 	WXFaceLayer *faceLayer = new WXFaceLayer(iFace, Nature::SILHOUETTE, true);
 	for (int i = 0; i < numVertices; i++) {
 		point = iFace->GetVertex(i)->GetVertex();
 		normal = iFace->GetVertexNormal(i);
 		normal.normalize();
-		Vec3r V;
+		Vec3f V;
 		if (_orthographicProjection) {
-			V = Vec3r(0.0, 0.0, _Viewpoint.z() - point.z());
+			V = Vec3f(0.0f, 0.0f, _Viewpoint.z() - point.z());
 		}
 		else {
-			V = Vec3r(_Viewpoint - point);
+			V = Vec3f(_Viewpoint - point);
 		}
 		V.normalize();
-		real d = normal * V;
+		float d = normal * V;
 		faceLayer->PushDotP(d);
 		// Find the point the closest to the viewpoint
 		if (_orthographicProjection) {
 			dist = point.z() - _Viewpoint.z();
 		}
 		else {
-			Vec3r dist_vec(point - _Viewpoint);
+			Vec3f dist_vec(point - _Viewpoint);
 			dist = dist_vec.norm();
 		}
 		if (dist < minDist) {
diff --git a/source/blender/freestyle/intern/view_map/FEdgeXDetector.h b/source/blender/freestyle/intern/view_map/FEdgeXDetector.h
index 9087d05..cbb47d3 100644
--- a/source/blender/freestyle/intern/view_map/FEdgeXDetector.h
+++ b/source/blender/freestyle/intern/view_map/FEdgeXDetector.h
@@ -98,7 +98,7 @@ public:
 	 *    a crease edge if the angle between two faces sharing the edge is smaller than the given threshold.
 	 */
 	// XXX angle should be in radian...
-	inline void setCreaseAngle(real angle)
+	inline void setCreaseAngle(float angle)
 	{
 		if (angle < 0.0)
 			angle = 0.0;
@@ -128,7 +128,7 @@ public:
 	 *  \param dkr
 	 *    The minimal derivative of the radial curvature
 	 */
-	inline void setSuggestiveContourKrDerivativeEpsilon(real dkr)
+	inline void setSuggestiveContourKrDerivativeEpsilon(float dkr)
 	{
 		if (dkr != _kr_derivative_epsilon) {
 			_kr_derivative_epsilon = dkr;
@@ -148,7 +148,7 @@ public:
 	virtual void buildSmoothEdges(WXShape *iShape);
 
 	/*! Sets the current viewpoint */
-	inline void setViewpoint(const Vec3r& ivp)
+	inline void setViewpoint(const Vec3f& ivp)
 	{
 		_Viewpoint = ivp;
 	}
@@ -193,7 +193,7 @@ public:
 	 *  \param r
 	 *    The radius of the sphere expressed as a ratio of the mean edge size
 	 */
-	inline void setSphereRadius(real r)
+	inline void setSphereRadius(float r)
 	{
 		if (r != _sphereRadius) {
 			_sphereRadius = r;
@@ -212,7 +212,7 @@ public:
 	}
 
 protected:
-	Vec3r _Viewpoint;
+	Vec3f _Viewpoint;
 #if 0
 	real _bbox_diagonal; // diagonal of the current processed shape bbox
 #endif
@@ -233,11 +233,11 @@ protected:
 	bool _computeMaterialBoundaries;
 	bool _faceSmoothness;
 	bool _faceMarks;
-	real _sphereRadius; // expressed as a ratio of the mean edge size
-	real _creaseAngle; // [-1, 1] compared with the inner product of face normals
+	float _sphereRadius; // expressed as a ratio of the mean edge size
+	float _creaseAngle; // [-1, 1] compared with the inner product of face normals
 	bool _changes;
 
-	real _kr_derivative_epsilon;
+	float _kr_derivative_epsilon;
 
 	ProgressBar *_pProgressBar;
 	RenderMonitor *_pRenderMonitor;




More information about the Bf-blender-cvs mailing list