code cleanup: replace cos(M_PI / 4) and sin(M_PI / 4) with M_SQRT1_2 define
authorCampbell Barton <ideasman42@gmail.com>
Sun, 22 Jul 2012 18:40:50 +0000 (18:40 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 22 Jul 2012 18:40:50 +0000 (18:40 +0000)
also some minor style cleanup.

intern/itasc/Armature.cpp
source/blender/blenkernel/intern/object.c
source/blender/editors/space_view3d/view3d_edit.c
source/blender/editors/space_view3d/view3d_view.c
source/blender/python/generic/bpy_internal_import.c

index 1dacb8bc184069309198e277b7c01021ed6cd929..78780ed8ba3055400ea37cd7fe31e5d50217b64b 100644 (file)
@@ -319,7 +319,7 @@ int Armature::addConstraint(const std::string& segment_name, ConstraintCallback
                        return iConstraint;
                }
        }
-       if (m_finalized)  {
+       if (m_finalized) {
                if (_freeParam && _param)
                        free(_param);
                return -1;
index 048560f3a834fbf408f5afb40b91d7d6f2f506c1..fa394d4a95119895aa32c3e11caf19b17d84ac8c 100644 (file)
@@ -1688,16 +1688,16 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4])
 
                if (cu->flag & CU_FOLLOW) {
 #if 0
-                       float x1, q[4];
+                       float si, q[4];
                        vec_to_quat(quat, dir, ob->trackflag, ob->upflag);
                        
                        /* the tilt */
                        normalize_v3(dir);
                        q[0] = (float)cos(0.5 * vec[3]);
-                       x1 = (float)sin(0.5 * vec[3]);
-                       q[1] = -x1 * dir[0];
-                       q[2] = -x1 * dir[1];
-                       q[3] = -x1 * dir[2];
+                       si = (float)sin(0.5 * vec[3]);
+                       q[1] = -si * dir[0];
+                       q[2] = -si * dir[1];
+                       q[3] = -si * dir[2];
                        mul_qt_qtqt(quat, q, quat);
 #else
                        quat_apply_track(quat, ob->trackflag, ob->upflag);
index e3a78f526cdcd05da6221e4c69db85162622fa23..6fbe75fb876ff5a559f14919da3589d3060c0162 100644 (file)
@@ -2873,7 +2873,7 @@ static int viewnumpad_exec(bContext *C, wmOperator *op)
                        break;
 
                case RV3D_VIEW_BACK:
-                       axis_set_view(C, v3d, ar, 0.0, 0.0, -cosf(M_PI / 4.0), -cosf(M_PI / 4.0),
+                       axis_set_view(C, v3d, ar, 0.0, 0.0, -M_SQRT1_2, -M_SQRT1_2,
                                      viewnum, nextperspo, align_active);
                        break;
 
@@ -2888,7 +2888,7 @@ static int viewnumpad_exec(bContext *C, wmOperator *op)
                        break;
 
                case RV3D_VIEW_FRONT:
-                       axis_set_view(C, v3d, ar, cosf(M_PI / 4.0), -sinf(M_PI / 4.0), 0.0, 0.0,
+                       axis_set_view(C, v3d, ar, M_SQRT1_2, -M_SQRT1_2, 0.0, 0.0,
                                      viewnum, nextperspo, align_active);
                        break;
 
index 3abfda78ec352e097593472b3aa78da332656d6c..f9776855d61d686cb6fa65f8a32c5222a1efa229 100644 (file)
@@ -1125,7 +1125,7 @@ int ED_view3d_lock(RegionView3D *rv3d)
                        break;
 
                case RV3D_VIEW_BACK:
-                       QUATSET(rv3d->viewquat, 0.0, 0.0, -cosf(M_PI / 4.0), -cosf(M_PI / 4.0));
+                       QUATSET(rv3d->viewquat, 0.0, 0.0, -M_SQRT1_2, -M_SQRT1_2);
                        break;
 
                case RV3D_VIEW_LEFT:
@@ -1137,7 +1137,7 @@ int ED_view3d_lock(RegionView3D *rv3d)
                        break;
 
                case RV3D_VIEW_FRONT:
-                       QUATSET(rv3d->viewquat, (float)cos(M_PI / 4.0), -sinf(M_PI / 4.0), 0.0, 0.0);
+                       QUATSET(rv3d->viewquat, M_SQRT1_2, -M_SQRT1_2, 0.0, 0.0);
                        break;
 
                case RV3D_VIEW_RIGHT:
index d4158210cc86c15e611521cfbed64518da4a130c..b9ef4b056ad3a3a37c055ec9b22961216d64c80a 100644 (file)
@@ -157,7 +157,8 @@ PyObject *bpy_text_import_name(const char *name, int *found)
        }
 
        /* we know this cant be importable, the name is too long for blender! */
-       if (namelen >= (MAX_ID_NAME - 2) - 3) return NULL;
+       if (namelen >= (MAX_ID_NAME - 2) - 3)
+               return NULL;
 
        memcpy(txtname, name, namelen);
        memcpy(&txtname[namelen], ".py", 4);