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:
authorThomas Dinges <blender@dingto.org>2013-05-10 16:51:30 +0400
committerThomas Dinges <blender@dingto.org>2013-05-10 16:51:30 +0400
commit96a11219f655a7a99853b8365b6f014a1db5d74b (patch)
tree2773206665a25326905030af1b56fff79ae71a88 /intern/cycles/blender/blender_curves.cpp
parent5424c1fe55966b3bc501a1f7e18bcdf667ce87f9 (diff)
Code cleanup / Cycles:
* Change some more if / else if conditions to switch / case. * Avoid an unneeded variable casting in phong_ramp closure.
Diffstat (limited to 'intern/cycles/blender/blender_curves.cpp')
-rw-r--r--intern/cycles/blender/blender_curves.cpp54
1 files changed, 29 insertions, 25 deletions
diff --git a/intern/cycles/blender/blender_curves.cpp b/intern/cycles/blender/blender_curves.cpp
index 4e0aad8ad14..584ac2f0ca4 100644
--- a/intern/cycles/blender/blender_curves.cpp
+++ b/intern/cycles/blender/blender_curves.cpp
@@ -73,31 +73,35 @@ ParticleCurveData::~ParticleCurveData()
void interp_weights(float t, float data[4], int type)
{
float t2, t3, fc;
-
- if(type == CURVE_LINEAR) {
- data[0] = 0.0f;
- data[1] = -t + 1.0f;
- data[2] = t;
- data[3] = 0.0f;
- }
- else if(type == CURVE_CARDINAL) {
- t2 = t * t;
- t3 = t2 * t;
- fc = 0.71f;
-
- data[0] = -fc * t3 + 2.0f * fc * t2 - fc * t;
- data[1] = (2.0f - fc) * t3 + (fc - 3.0f) * t2 + 1.0f;
- data[2] = (fc - 2.0f) * t3 + (3.0f - 2.0f * fc) * t2 + fc * t;
- data[3] = fc * t3 - fc * t2;
- }
- else if(type == CURVE_BSPLINE) {
- t2 = t * t;
- t3 = t2 * t;
-
- data[0] = -0.16666666f * t3 + 0.5f * t2 - 0.5f * t + 0.16666666f;
- data[1] = 0.5f * t3 - t2 + 0.66666666f;
- data[2] = -0.5f * t3 + 0.5f * t2 + 0.5f * t + 0.16666666f;
- data[3] = 0.16666666f * t3;
+
+ switch (type) {
+ case CURVE_LINEAR:
+ data[0] = 0.0f;
+ data[1] = -t + 1.0f;
+ data[2] = t;
+ data[3] = 0.0f;
+ break;
+ case CURVE_CARDINAL:
+ t2 = t * t;
+ t3 = t2 * t;
+ fc = 0.71f;
+
+ data[0] = -fc * t3 + 2.0f * fc * t2 - fc * t;
+ data[1] = (2.0f - fc) * t3 + (fc - 3.0f) * t2 + 1.0f;
+ data[2] = (fc - 2.0f) * t3 + (3.0f - 2.0f * fc) * t2 + fc * t;
+ data[3] = fc * t3 - fc * t2;
+ break;
+ case CURVE_BSPLINE:
+ t2 = t * t;
+ t3 = t2 * t;
+
+ data[0] = -0.16666666f * t3 + 0.5f * t2 - 0.5f * t + 0.16666666f;
+ data[1] = 0.5f * t3 - t2 + 0.66666666f;
+ data[2] = -0.5f * t3 + 0.5f * t2 + 0.5f * t + 0.16666666f;
+ data[3] = 0.16666666f * t3;
+ break;
+ default:
+ break;
}
}