Browse Source

remove excess floor()'s

cxgeorge 24 years ago
parent
commit
3ae41dd434

+ 1 - 1
panda/src/chan/animControl.I

@@ -72,7 +72,7 @@ get_frame_rate() const {
 ////////////////////////////////////////////////////////////////////
 INLINE int AnimControl::
 get_frame() const {
-  return (int)floor(_frame + 0.0001);
+  return (int)(_frame + 0.0001);
 }
 
 ////////////////////////////////////////////////////////////////////

+ 2 - 2
panda/src/chan/animControl.cxx

@@ -382,7 +382,7 @@ advance_time(double time) {
         do_actions_backward(orig_frame-1, new_frame);
       } else {
         if (do_actions_backward(orig_frame-1, 0)) {
-          _frame = _frame - floor(_frame / num_frames) * num_frames;
+          _frame = _frame - (int)(_frame / num_frames) * num_frames;
           new_frame = get_frame();
           do_actions_backward(get_num_frames(), new_frame);
         }
@@ -394,7 +394,7 @@ advance_time(double time) {
         do_actions_forward(orig_frame+1, new_frame);
       } else {
         if (do_actions_forward(orig_frame+1, get_num_frames()-1)) {
-          _frame = _frame - floor(_frame / num_frames) * num_frames;
+          _frame = _frame - (int)(_frame / num_frames) * num_frames;
           new_frame = get_frame();
           do_actions_forward(0, new_frame);
         }

+ 6 - 6
panda/src/parametrics/classicNurbsCurve.cxx

@@ -157,12 +157,12 @@ get_num_knots() const {
 bool ClassicNurbsCurve::
 insert_cv(float t) {
   if (_cvs.empty()) {
-    append_cv(0.0, 0.0, 0.0);
+    append_cv(0.0f, 0.0f, 0.0f);
     return true;
   }
 
   if (t <= 0) {
-    t = 0.0;
+    t = 0.0f;
   }
 
   int k = find_cv(t);
@@ -183,11 +183,11 @@ insert_cv(float t) {
     int nk = i + k - (_order-1);
     float ti = get_knot(nk);
     float d = get_knot(nk + _order-1) - ti;
-    if (d == 0.0) {
+    if (d == 0.0f) {
       new_cvs[i] = _cvs[nk-1]._p;
     } else {
       float a = (t - ti) / d;
-      new_cvs[i] = (1.0-a)*_cvs[nk-1]._p + a*_cvs[nk]._p;
+      new_cvs[i] = (1.0f-a)*_cvs[nk-1]._p + a*_cvs[nk]._p;
     }
   }
 
@@ -289,7 +289,7 @@ set_knot(int n, float t) {
 float ClassicNurbsCurve::
 get_knot(int n) const {
   if (n < _order || _cvs.empty()) {
-    return 0.0;
+    return 0.0f;
   } else if (n-1 >= (int)_cvs.size()) {
     return _cvs.back()._t;
   } else {
@@ -514,7 +514,7 @@ write(ostream &out, int indent_level) const {
 ////////////////////////////////////////////////////////////////////
 int ClassicNurbsCurve::
 append_cv_impl(const LVecBase4f &v) {
-  _cvs.push_back(CV(v, get_knot(_cvs.size())+1.0));
+  _cvs.push_back(CV(v, get_knot(_cvs.size())+1.0f));
   return _cvs.size()-1;
 }
 

+ 39 - 33
panda/src/parametrics/cubicCurveseg.cxx

@@ -94,7 +94,8 @@ CubicCurveseg::
 ////////////////////////////////////////////////////////////////////
 bool CubicCurveseg::
 get_point(float t, LVecBase3f &point) const {
-  evaluate_point(LVecBase4f(t*t*t, t*t, t, 1.0), point);
+  float t_sqrd = t*t;
+  evaluate_point(LVecBase4f(t*t_sqrd, t_sqrd, t, 1.0f), point);
   return true;
 }
 
@@ -106,7 +107,7 @@ get_point(float t, LVecBase3f &point) const {
 ////////////////////////////////////////////////////////////////////
 bool CubicCurveseg::
 get_tangent(float t, LVecBase3f &tangent) const {
-  evaluate_vector(LVecBase4f(3.0*t*t, 2.0*t, 1.0, 0.0), tangent);
+  evaluate_vector(LVecBase4f(3.0f*t*t, 2.0f*t, 1.0f, 0.0f), tangent);
   return true;
 }
 
@@ -118,8 +119,9 @@ get_tangent(float t, LVecBase3f &tangent) const {
 ////////////////////////////////////////////////////////////////////
 bool CubicCurveseg::
 get_pt(float t, LVecBase3f &point, LVecBase3f &tangent) const {
-  evaluate_point(LVecBase4f(t*t*t, t*t, t, 1.0), point);
-  evaluate_vector(LVecBase4f(3.0*t*t, 2.0*t, 1.0, 0.0), tangent);
+  float t_sqrd=t*t;
+  evaluate_point(LVecBase4f(t*t_sqrd, t_sqrd, t, 1.0f), point);
+  evaluate_vector(LVecBase4f(3.0f*t_sqrd, /*2.0f*t*/t+t, 1.0f, 0.0f), tangent);
   return true;
 }
 
@@ -131,7 +133,7 @@ get_pt(float t, LVecBase3f &point, LVecBase3f &tangent) const {
 ////////////////////////////////////////////////////////////////////
 bool CubicCurveseg::
 get_2ndtangent(float t, LVecBase3f &tangent2) const {
-  evaluate_vector(LVecBase4f(6.0*t, 2.0, 0.0, 0.0), tangent2);
+  evaluate_vector(LVecBase4f(6.0f*t, 2.0f, 0.0f, 0.0f), tangent2);
   return true;
 }
 
@@ -148,10 +150,10 @@ hermite_basis(const HermiteCurveCV &cv0,
               const HermiteCurveCV &cv1,
               float tlength) {
   static LMatrix4f
-    Mh(2, -3, 0, 1,
-       -2, 3, 0, 0,
-       1, -2, 1, 0,
-       1, -1, 0, 0);
+    Mh( 2.0f, -3.0f, 0.0f, 1.0f,
+       -2.0f,  3.0f, 0.0f, 0.0f,
+        1.0f, -2.0f, 1.0f, 0.0f,
+        1.0f, -1.0f, 0.0f, 0.0f);
 
   LVecBase4f Gx(cv0._p[0], cv1._p[0],
                 cv0._out[0]*tlength, cv1._in[0]*tlength);
@@ -176,10 +178,10 @@ hermite_basis(const HermiteCurveCV &cv0,
 void CubicCurveseg::
 bezier_basis(const BezierSeg &seg) {
   static LMatrix4f
-    Mb(-1, 3, -3, 1,
-       3, -6, 3, 0,
-       -3, 3, 0, 0,
-       1, 0, 0, 0);
+    Mb(-1.0f,  3.0f, -3.0f, 1.0f,
+        3.0f, -6.0f,  3.0f, 0.0f,
+       -3.0f,  3.0f,  0.0f, 0.0f,
+        1.0f,  0.0f,  0.0f, 0.0f);
 
   LVecBase4f Gx(seg._v[0][0], seg._v[1][0], seg._v[2][0], seg._v[3][0]);
   LVecBase4f Gy(seg._v[0][1], seg._v[1][1], seg._v[2][1], seg._v[3][1]);
@@ -199,9 +201,9 @@ nurbs_blending_function(int order, int i, int j,
 
   if (j==1) {
     if (i==order-1 && knots[i] < knots[i+1]) {
-      r.set(0.0, 0.0, 0.0, 1.0);
+      r.set(0.0f, 0.0f, 0.0f, 1.0f);
     } else {
-      r.set(0.0, 0.0, 0.0, 0.0);
+      r.set(0.0f, 0.0f, 0.0f, 0.0f);
     }
 
   } else {
@@ -212,35 +214,35 @@ nurbs_blending_function(int order, int i, int j,
     float d1 = knots[i+j] - knots[i+1];
 
     // First term.  Division by zero is defined to equal zero.
-    if (d0 != 0.0) {
-      if (d1 != 0.0) {
+    if (d0 != 0.0f) {
+      if (d1 != 0.0f) {
         r = bi0 / d0 - bi1 / d1;
       } else {
         r = bi0 / d0;
       }
 
-    } else if (d1 != 0.0) {
+    } else if (d1 != 0.0f) {
       r = - bi1 / d1;
 
     } else {
-      r.set(0.0, 0.0, 0.0, 0.0);
+      r.set(0.0f, 0.0f, 0.0f, 0.0f);
     }
 
     // scale by t.
     r[0] = r[1];
     r[1] = r[2];
     r[2] = r[3];
-    r[3] = 0.0;
+    r[3] = 0.0f;
 
     // Second term.
-    if (d0 != 0.0) {
-      if (d1 != 0.0) {
+    if (d0 != 0.0f) {
+      if (d1 != 0.0f) {
         r += bi0 * (- knots[i] / d0) + bi1 * (knots[i+j] / d1);
       } else {
         r += bi0 * (- knots[i] / d0);
       }
 
-    } else if (d1 != 0.0) {
+    } else if (d1 != 0.0f) {
       r += bi1 * (knots[i+j] / d1);
     }
   }
@@ -307,7 +309,7 @@ nurbs_basis(int order, const float knots[], const LVecBase4f cvs[]) {
   // elements.
   LVecBase4f c[4];
   for (int i = 0; i < 4; i++) {
-    c[i] = (i<order) ? cvs[i] : LVecBase4f(0.0, 0.0, 0.0, 0.0);
+    c[i] = (i<order) ? cvs[i] : LVecBase4f(0.0f, 0.0f, 0.0f, 0.0f);
   }
 
   Bx = LVecBase4f(c[0][0], c[1][0], c[2][0], c[3][0]) * B;
@@ -329,10 +331,10 @@ nurbs_basis(int order, const float knots[], const LVecBase4f cvs[]) {
 bool CubicCurveseg::
 get_bezier_seg(BezierSeg &seg) const {
   static LMatrix4f
-    Mbi(0.0, 0.0, 0.0, 1.0,
-        0.0, 0.0, 1.0/3.0, 1.0,
-        0.0, 1.0/3.0, 2.0/3.0, 1.0,
-        1.0, 1.0, 1.0, 1.0);
+    Mbi(0.0f, 0.0f, 0.0f, 1.0f,
+        0.0f, 0.0f, 1.0f/3.0f, 1.0f,
+        0.0f, 1.0f/3.0f, 2.0f/3.0f, 1.0f,
+        1.0f, 1.0f, 1.0f, 1.0f);
 
   LVecBase4f Gx = Bx * Mbi;
   LVecBase4f Gy = By * Mbi;
@@ -354,7 +356,6 @@ get_bezier_seg(BezierSeg &seg) const {
   return true;
 }
 
-
 // We need this operator since Performer didn't supply it.
 inline LVecBase4f
 col_mult(const LMatrix4f &M, const LVecBase4f &v) {
@@ -390,10 +391,14 @@ compute_seg_col(int c,
   switch (rtype & RT_BASE_TYPE) {
     // RT_point defines the point on the curve at t.  This is the vector
     // [ t^3 t^2 t^1 t^0 ].
+    float t_sqrd,t_cubed;
+
   case RT_POINT:
-    T.set_col(c, LVecBase4f(t*t*t, t*t, t, 1.0));
+    t_sqrd = t*t;
+    t_cubed = t_sqrd*t;
+    T.set_col(c, LVecBase4f(t_cubed, t_sqrd, t, 1.0f));
     if (keep_orig) {
-      LVecBase4f vec(t*t*t, t*t, t, 1.0);
+      LVecBase4f vec(t_cubed, t_sqrd, t, 1.0f);
       LVecBase4f ov = col_mult(GB, vec);
       if (parametrics_cat.is_debug()) {
         parametrics_cat.debug()
@@ -408,9 +413,10 @@ compute_seg_col(int c,
     // RT_tangent defines the tangent to the curve at t.  This is
     // the vector [ 3t^2 2t 1 0 ].
   case RT_TANGENT:
-    T.set_col(c, LVecBase4f(3.0*t*t, 2.0*t, 1.0, 0.0));
+    t_sqrd = t*t;
+    T.set_col(c, LVecBase4f(3.0f*t_sqrd, t+t, 1.0f, 0.0f));
     if (keep_orig) {
-      LVecBase4f vec(3.0*t*t, 2.0*t, 1.0, 0.0);
+      LVecBase4f vec(3.0f*t_sqrd, /*2.0f*t*/t+t, 1.0f, 0.0f);
       LVecBase4f ov = col_mult(GB, vec);
       if (parametrics_cat.is_debug()) {
         parametrics_cat.debug()

+ 5 - 5
panda/src/parametrics/cubicCurveseg.h

@@ -76,7 +76,7 @@ public:
 
   void hermite_basis(const HermiteCurveCV &cv0,
                      const HermiteCurveCV &cv1,
-                     float tlength = 1.0);
+                     float tlength = 1.0f);
   void bezier_basis(const BezierSeg &seg);
   void nurbs_basis(int order, const float knots[], const LVecBase4f cvs[]);
 
@@ -92,10 +92,10 @@ public:
   // would be zero anyway).
 
   void evaluate_point(const LVecBase4f &tv, LVecBase3f &result) const {
-    float h = (rational) ? tv.dot(Bw) : 1.0;
-    result.set(tv.dot(Bx) / h,
-               tv.dot(By) / h,
-               tv.dot(Bz) / h);
+    float recip_h = (rational) ? 1.0f/tv.dot(Bw) : 1.0f;
+    result.set(tv.dot(Bx) * recip_h,
+               tv.dot(By) * recip_h,
+               tv.dot(Bz) * recip_h);
   }
 
   void evaluate_vector(const LVecBase4f &tv, LVecBase3f &result) const {

+ 5 - 5
panda/src/parametrics/curveFitter.I

@@ -24,11 +24,11 @@
 ////////////////////////////////////////////////////////////////////
 INLINE CurveFitter::DataPoint::
 DataPoint() :
-  _t(0.0),
-  _xyz(0.0, 0.0, 0.0),
-  _hpr(0.0, 0.0, 0.0),
-  _tangent(0.0, 0.0, 0.0),
-  _hpr_tangent(0.0, 0.0, 0.0)
+  _t(0.0f),
+  _xyz(0.0f, 0.0f, 0.0f),
+  _hpr(0.0f, 0.0f, 0.0f),
+  _tangent(0.0f, 0.0f, 0.0f),
+  _hpr_tangent(0.0f, 0.0f, 0.0f)
 {
 }
 

+ 21 - 20
panda/src/parametrics/curveFitter.cxx

@@ -121,7 +121,7 @@ get_num_samples() const {
 ////////////////////////////////////////////////////////////////////
 float CurveFitter::
 get_sample_t(int n) const {
-  nassertr(n >= 0 && n < (int)_data.size(), 0.0);
+  nassertr(n >= 0 && n < (int)_data.size(), 0.0f);
   return _data[n]._t;
 }
 
@@ -191,8 +191,8 @@ sample(ParametricCurveCollection *curves, int count) {
   float t, last_t, d;
   DataPoint dp;
 
-  last_t = 0.0;
-  d = 0.0;
+  last_t = 0.0f;
+  d = 0.0f;
   int i;
   for (i = 0; i < count; i++) {
     t = max_t * (float)i / (float)(count-1);
@@ -222,22 +222,22 @@ sample(ParametricCurveCollection *curves, int count) {
 void CurveFitter::
 wrap_hpr() {
   Data::iterator di;
-  LVecBase3f last(0.0, 0.0, 0.0);
-  LVecBase3f net(0.0, 0.0, 0.0);
+  LVecBase3f last(0.0f, 0.0f, 0.0f);
+  LVecBase3f net(0.0f, 0.0f, 0.0f);
 
   for (di = _data.begin(); di != _data.end(); ++di) {
     int i;
     for (i = 0; i < 3; i++) {
       (*di)._hpr[i] += net[i];
 
-      while (((*di)._hpr[i] - last[i]) > 180.0) {
-        (*di)._hpr[i] -= 360.0;
-        net[i] -= 360.0;
+      while (((*di)._hpr[i] - last[i]) > 180.0f) {
+        (*di)._hpr[i] -= 360.0f;
+        net[i] -= 360.0f;
       }
 
-      while (((*di)._hpr[i] - last[i]) < -180.0) {
-        (*di)._hpr[i] += 360.0;
-        net[i] += 360.0;
+      while (((*di)._hpr[i] - last[i]) < -180.0f) {
+        (*di)._hpr[i] += 360.0f;
+        net[i] += 360.0f;
       }
 
       last[i] = (*di)._hpr[i];
@@ -276,7 +276,7 @@ desample(float factor) {
       out++;
       count -= factor;
     }
-    count += 1.0;
+    count += 1.0f;
   }
 
   _data[out] = _data.back();
@@ -301,11 +301,11 @@ compute_tangents(float scale) {
 
   if (_got_xyz) {
     closed =
-      (_data.front()._xyz.almost_equal(_data.back()._xyz, 0.001));
+      (_data.front()._xyz.almost_equal(_data.back()._xyz, 0.001f));
 
   } else if (_got_hpr) {
     closed =
-      (_data.front()._hpr.almost_equal(_data.back()._hpr, 0.001));
+      (_data.front()._hpr.almost_equal(_data.back()._hpr, 0.001f));
   }
 
   int i;
@@ -346,18 +346,18 @@ compute_tangents(float scale) {
     if (_got_xyz) {
       _data[0]._tangent =
         (_data[1]._xyz - _data[0]._xyz) * scale /
-        ((_data[1]._t - _data[0]._t) * 2.0);
+        ((_data[1]._t - _data[0]._t) * 2.0f);
       _data[len-1]._tangent =
         (_data[len-1]._xyz - _data[len-2]._xyz) * scale /
-        ((_data[len-1]._t - _data[len-2]._t) * 2.0);
+        ((_data[len-1]._t - _data[len-2]._t) * 2.0f);
     }
     if (_got_hpr) {
       _data[0]._tangent =
         (_data[1]._hpr - _data[0]._hpr) * scale /
-        ((_data[1]._t - _data[0]._t) * 2.0);
+        ((_data[1]._t - _data[0]._t) * 2.0f);
       _data[len-1]._tangent =
         (_data[len-1]._hpr - _data[len-2]._hpr) * scale /
-        ((_data[len-1]._t - _data[len-2]._t) * 2.0);
+        ((_data[len-1]._t - _data[len-2]._t) * 2.0f);
     }
   }
 }
@@ -443,11 +443,12 @@ make_nurbs() const {
 
     int i;
     float k1, k2 = nc->get_knot(num_knots-1);
+    const float one_third = 1.0f/3.0f;
     for (i = 3; i < num_knots - 4; i += 3) {
       k1 = nc->get_knot(i-1);
       k2 = nc->get_knot(i+2);
-      nc->set_knot(i, (k1 + k1 + k2) / 3.0);
-      nc->set_knot(i+1, (k1 + k2 + k2) / 3.0);
+      nc->set_knot(i, (k1 + k1 + k2) * one_third);
+      nc->set_knot(i+1, (k1 + k2 + k2) * one_third);
     }
 
     // The last knot must have the terminal value.

+ 11 - 11
panda/src/parametrics/hermiteCurve.cxx

@@ -31,7 +31,7 @@
 
 TypeHandle HermiteCurve::_type_handle;
 
-static const LVecBase3f zerovec_3f = LVecBase3f(0.0, 0.0, 0.0);
+static const LVecBase3f zerovec_3f = LVecBase3f(0.0f, 0.0f, 0.0f);
 // This is returned occasionally from some of the functions, and is
 // used from time to time as an initializer.
 
@@ -98,7 +98,7 @@ set_in(const LVecBase3f &in) {
   switch (_type) {
   case HC_G1:
     l = _in.length();
-    if (l!=0.0) {
+    if (l!=0.0f) {
       _out = _in * _out.length() / l;
     }
     break;
@@ -124,7 +124,7 @@ set_out(const LVecBase3f &out) {
   switch (_type) {
   case HC_G1:
     l = _out.length();
-    if (l!=0.0) {
+    if (l!=0.0f) {
       _in = _out * _in.length() / l;
     }
     break;
@@ -329,7 +329,7 @@ get_num_cvs() const {
 int HermiteCurve::
 insert_cv(float t) {
   if (!is_valid() || t >= get_max_t()) {
-    int n = append_cv(HC_SMOOTH, 0.0, 0.0, 0.0);
+    int n = append_cv(HC_SMOOTH, 0.0f, 0.0f, 0.0f);
     set_cv_tstart(n, t);
     return n;
   }
@@ -343,7 +343,7 @@ insert_cv(float t) {
   LVecBase3f tan;
   cv._type = HC_SMOOTH;
   get_pt(t, cv._p, tan);
-  cv._out = cv._in = tan / 2.0;
+  cv._out = cv._in = tan * 0.5f;
 
   _points.insert(_points.begin() + n + 1, cv);
   bool result =
@@ -374,7 +374,7 @@ append_cv(int type, float x, float y, float z) {
   _points.push_back(cv);
   if (_points.size()>1) {
     bool result =
-      insert_curveseg(_segs.size(), new CubicCurveseg, 1.0);
+      insert_curveseg(_segs.size(), new CubicCurveseg, 1.0f);
     nassertr(result, 0);
   }
 
@@ -519,7 +519,7 @@ set_cv_tstart(int n, float tstart) {
   if (n <= 0 || n >= (int)_points.size()) {
     return false;
   }
-  if (fabs(tstart - get_cv_tstart(n)) > 0.0001) {
+  if (fabs(tstart - get_cv_tstart(n)) > 0.0001f) {
     set_tlength(n-1, tstart - get_tstart(n-1));
     recompute_basis();
     invalidate_all();
@@ -627,7 +627,7 @@ get_cv_out(int n, LVecBase3f &v) const {
 float HermiteCurve::
 get_cv_tstart(int n) const {
   if (n<0) {
-    return 0.0;
+    return 0.0f;
   } else if (n >= (int)_points.size()) {
     return get_max_t();
   }
@@ -757,8 +757,8 @@ format_egg(ostream &out, const string &name, const string &curve_type,
     bool show_out = (i != (int)_points.size()-1);
     _points[i].format_egg(out, indent_level + 2, _num_dimensions,
                           show_in, show_out,
-                          show_in ? get_tlength(i-1) : 0.0,
-                          show_out ? get_tlength(i) : 0.0);
+                          show_in ? get_tlength(i-1) : 0.0f,
+                          show_out ? get_tlength(i) : 0.0f);
   }
   indent(out, indent_level) << "}\n";
 
@@ -821,7 +821,7 @@ wrap_hpr(const LVecBase3f &hpr1, LVecBase3f &hpr2) {
 ////////////////////////////////////////////////////////////////////
 void HermiteCurve::
 invalidate_cv(int n, bool redo_all) {
-  float t1 = 0.0, t2 = get_max_t();
+  float t1 = 0.0f, t2 = get_max_t();
   if (n>0 && _points[n-1]._type!=HC_CUT) {
     const HermiteCurveCV &p1 = _points[n-1];
     HermiteCurveCV p2(_points[n]);

+ 1 - 1
panda/src/parametrics/nurbsCurveDrawer.I

@@ -26,6 +26,6 @@
 ////////////////////////////////////////////////////////////////////
 INLINE bool NurbsCurveDrawer::
 hilight(int n) {
-  return hilight(n, 1.0, 1.0, 0.0);
+  return hilight(n, 1.0f, 1.0f, 0.0f);
 }
 

+ 7 - 7
panda/src/parametrics/nurbsCurveDrawer.cxx

@@ -31,13 +31,13 @@ TypeHandle NurbsCurveDrawer::_type_handle;
 ////////////////////////////////////////////////////////////////////
 NurbsCurveDrawer::
 NurbsCurveDrawer() {
-  set_cv_color(1.0, 0.0, 0.0);
-  set_hull_color(1.0, 0.5, 0.5);
-  set_knot_color(0.0, 0.0, 1.0);
+  set_cv_color(1.0f, 0.0f, 0.0f);
+  set_hull_color(1.0f, 0.5, 0.5);
+  set_knot_color(0.0f, 0.0f, 1.0f);
 
-  _cvs.set_thickness(4.0);
-  _hull.set_thickness(1.0);
-  _knots.set_thickness(4.0);
+  _cvs.set_thickness(4.0f);
+  _hull.set_thickness(1.0f);
+  _knots.set_thickness(4.0f);
 
   _show_cvs = true;
   _show_hull = true;
@@ -130,7 +130,7 @@ draw() {
     _num_cvs = nurbs->get_num_cvs();
     _knotnums.erase(_knotnums.begin(), _knotnums.end());
 
-    float lt = -1.0;
+    float lt = -1.0f;
     int ki = -1;
     for (i = 0; i < _num_cvs; i++) {
       float t = nurbs->get_knot(i);

+ 3 - 3
panda/src/parametrics/nurbsCurveInterface.I

@@ -34,7 +34,7 @@ append_cv(float x, float y, float z) {
 ////////////////////////////////////////////////////////////////////
 INLINE int NurbsCurveInterface::
 append_cv(const LVecBase3f &v) {
-  return append_cv(LVecBase4f(v[0], v[1], v[2], 1.0));
+  return append_cv(LVecBase4f(v[0], v[1], v[2], 1.0f));
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -67,7 +67,7 @@ set_cv_point(int n, float x, float y, float z) {
 INLINE bool NurbsCurveInterface::
 set_cv_point(int n, const LVecBase3f &v) {
   nassertr(n >= 0 && n < get_num_cvs(), false);
-  return set_cv(n, LVecBase4f(v[0], v[1], v[2], 1.0) * get_cv_weight(n));
+  return set_cv(n, LVecBase4f(v[0], v[1], v[2], 1.0f) * get_cv_weight(n));
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -79,7 +79,7 @@ INLINE LVecBase3f NurbsCurveInterface::
 get_cv_point(int n) const {
   nassertr(n >= 0 && n < get_num_cvs(), LVecBase3f::zero());
   LVecBase4f p = get_cv(n);
-  nassertr(p[3] != 0.0, LVecBase3f::zero());
+  nassertr(p[3] != 0.0f, LVecBase3f::zero());
   return LVecBase3f(p[0], p[1], p[2]) / p[3];
 }
 

+ 4 - 4
panda/src/parametrics/nurbsCurveInterface.cxx

@@ -32,8 +32,8 @@ bool NurbsCurveInterface::
 set_cv_weight(int n, float w) {
   nassertr(n >= 0 && n < get_num_cvs(), false);
   LVecBase4f cv = get_cv(n);
-  if (cv[3] == 0.0) {
-    cv.set(0.0, 0.0, 0.0, w);
+  if (cv[3] == 0.0f) {
+    cv.set(0.0f, 0.0f, 0.0f, w);
   } else {
     cv *= w / cv[3];
   }
@@ -62,8 +62,8 @@ void NurbsCurveInterface::
 write(ostream &out, int indent_level) const {
   indent(out, indent_level);
 
-  float min_t = 0.0;
-  float max_t = 0.0;
+  float min_t = 0.0f;
+  float max_t = 0.0f;
 
   if (get_num_knots() > 0) {
     min_t = get_knot(0);

+ 18 - 18
panda/src/parametrics/nurbsPPCurve.cxx

@@ -82,7 +82,7 @@ NurbsPPCurve::
 //     Function: NurbsPPCurve::get_max_t
 //       Access: Published, Virtual
 //  Description: Returns the upper bound of t for the entire curve.
-//               The curve is defined in the range 0.0 <= t <=
+//               The curve is defined in the range 0.0f <= t <=
 //               get_max_t().
 ////////////////////////////////////////////////////////////////////
 float NurbsPPCurve::
@@ -92,7 +92,7 @@ get_max_t() const {
 
   } else {
     if (_knots.empty()) {
-      return 0.0;
+      return 0.0f;
     } else {
       return _knots.back();
     }
@@ -279,12 +279,12 @@ set_knot(int n, float t) {
 ////////////////////////////////////////////////////////////////////
 float NurbsPPCurve::
 get_knot(int n) const {
-  nassertr(n >= 0 && n < get_num_knots(), 0.0);
+  nassertr(n >= 0 && n < get_num_knots(), 0.0f);
 
   if (_nurbs_valid) {
     return _nurbs.knot(n);
   } else {
-    nassertr(n >= 0 && n < (int)_knots.size(), 0.0);
+    nassertr(n >= 0 && n < (int)_knots.size(), 0.0f);
     return _knots[n];
   }
 }
@@ -308,7 +308,7 @@ recompute() {
 //     Function: NurbsPPCurve::get_point
 //       Access: Public, Virtual
 //  Description: Returns the point of the curve at a given parametric
-//               point t.  Returns true if t is in the valid range 0.0
+//               point t.  Returns true if t is in the valid range 0.0f
 //               <= t <= get_max_t(); if t is outside this range, sets
 //               point to the value of the curve at the beginning or
 //               end (whichever is nearer) and returns false.
@@ -320,8 +320,8 @@ get_point(float t, LVecBase3f &point) const {
   bool in_range = true;
   float max_t = get_max_t();
 
-  if (t < 0.0) {
-    t = 0.0;
+  if (t < 0.0f) {
+    t = 0.0f;
     in_range = false;
 
   } else if (t > max_t) {
@@ -338,7 +338,7 @@ get_point(float t, LVecBase3f &point) const {
 //     Function: NurbsPPCurve::get_tangent
 //       Access: Public, Virtual
 //  Description: Returns the tangent of the curve at a given parametric
-//               point t.  Returns true if t is in the valid range 0.0
+//               point t.  Returns true if t is in the valid range 0.0f
 //               <= t <= get_max_t(); if t is outside this range, sets
 //               tangent to the value of the curve at the beginning or
 //               end (whichever is nearer) and returns false.
@@ -350,8 +350,8 @@ get_tangent(float t, LVecBase3f &tangent) const {
   bool in_range = true;
   float max_t = get_max_t();
 
-  if (t < 0.0) {
-    t = 0.0;
+  if (t < 0.0f) {
+    t = 0.0f;
     in_range = false;
 
   } else if (t > max_t) {
@@ -377,8 +377,8 @@ get_pt(float t, LVecBase3f &point, LVecBase3f &tangent) const {
   bool in_range = true;
   float max_t = get_max_t();
 
-  if (t < 0.0) {
-    t = 0.0;
+  if (t < 0.0f) {
+    t = 0.0f;
     in_range = false;
 
   } else if (t > max_t) {
@@ -398,7 +398,7 @@ get_pt(float t, LVecBase3f &point, LVecBase3f &tangent) const {
 //       Access: Public, Virtual
 //  Description: Returns the second derivative of the curve at a given
 //               parametric point t.  Returns true if t is in the
-//               valid range 0.0 <= t <= get_max_t(); if t is outside
+//               valid range 0.0f <= t <= get_max_t(); if t is outside
 //               this range, sets tangent to the value of the curve at
 //               the beginning or end (whichever is nearer) and
 //               returns false.
@@ -410,8 +410,8 @@ get_2ndtangent(float t, LVecBase3f &tangent2) const {
   bool in_range = true;
   float max_t = get_max_t();
 
-  if (t < 0.0) {
-    t = 0.0;
+  if (t < 0.0f) {
+    t = 0.0f;
     in_range = false;
 
   } else if (t > max_t) {
@@ -539,11 +539,11 @@ append_cv_impl(const LVecBase4f &cv) {
 
   if (_knots.empty()) {
     for (int i = 0; i < _order; i++) {
-      _knots.push_back(0.0);
+      _knots.push_back(0.0f);
     }
-    _knots.push_back(1.0);
+    _knots.push_back(1.0f);
   } else {
-    _knots.push_back(_knots.back() + 1.0);
+    _knots.push_back(_knots.back() + 1.0f);
   }
 
   return _points.size() - 1;

+ 35 - 32
panda/src/parametrics/parametricCurve.cxx

@@ -90,14 +90,14 @@ is_valid() const {
 //     Function: ParametricCurve::get_max_t
 //       Access: Published, Virtual
 //  Description: Returns the upper bound of t for the entire curve.
-//               The curve is defined in the range 0.0 <= t <=
+//               The curve is defined in the range 0.0f <= t <=
 //               get_max_t().  This base class function always returns
-//               1.0; derived classes might override this to return
+//               1.0f; derived classes might override this to return
 //               something else.
 ////////////////////////////////////////////////////////////////////
 float ParametricCurve::
 get_max_t() const {
-  return 1.0;
+  return 1.0f;
 }
 
 
@@ -184,7 +184,7 @@ get_num_dimensions() const {
 ////////////////////////////////////////////////////////////////////
 float ParametricCurve::
 calc_length() const {
-  return calc_length(0.0, get_max_t());
+  return calc_length(0.0f, get_max_t());
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -200,17 +200,20 @@ calc_length(float from, float to) const {
 
   // Normally we expect from < to.  If they came in backwards, reverse
   // them.
-  if (to < from) {
+  float to_minus_from = to - from;
+
+  if (to_minus_from < 0.0f) {
     float temp = to;
     to = from;
     from = temp;
+    to_minus_from=-to_minus_from;
   }
 
   // Start with a segment for each unit of t.
-  int num_segs = (int)floor(to - from + 1);
+  int num_segs = (int)(to_minus_from) + 1;
   t2 = from;
   get_point(t2, p2);
-  float net = 0.0;
+  float net = 0.0f;
 
   for (int i = 1; i <= num_segs; i++) {
     t1 = t2;
@@ -240,8 +243,8 @@ calc_length(float from, float to) const {
 ////////////////////////////////////////////////////////////////////
 float ParametricCurve::
 find_length(float start_t, float length_offset) const {
-  nassertr(length_offset >= 0.0, start_t);
-  nassertr(start_t >= 0.0 && start_t <= get_max_t(), start_t);
+  nassertr(length_offset >= 0.0f, start_t);
+  nassertr(start_t >= 0.0f && start_t <= get_max_t(), start_t);
 
   float t1, t2;
   LPoint3f p1, p2;
@@ -251,7 +254,7 @@ find_length(float start_t, float length_offset) const {
   int num_segs = (int)floor(max_t - start_t + 1);
   t2 = start_t;
   get_point(t2, p2);
-  float net = 0.0;
+  float net = 0.0f;
 
   for (int i = 1; i <= num_segs; i++) {
     t1 = t2;
@@ -502,32 +505,32 @@ convert_to_hermite(HermiteCurve *hc) const {
 
   int i, n;
   if (!bz_segs.empty()) {
-    float scale_in = 0.0;
+    float scale_in = 0.0f;
     float scale_out = bz_segs[0]._t;
     n = hc->append_cv(HC_SMOOTH, bz_segs[0]._v[0]);
-    hc->set_cv_out(n, 3.0 * (bz_segs[0]._v[1] - bz_segs[0]._v[0]) / scale_out);
+    hc->set_cv_out(n, 3.0f * (bz_segs[0]._v[1] - bz_segs[0]._v[0]) / scale_out);
 
     for (i = 0; i < (int)bz_segs.size()-1; i++) {
       scale_in = scale_out;
       scale_out = bz_segs[i+1]._t - bz_segs[i]._t;
 
-      if (!bz_segs[i]._v[3].almost_equal(bz_segs[i+1]._v[0], 0.0001)) {
+      if (!bz_segs[i]._v[3].almost_equal(bz_segs[i+1]._v[0], 0.0001f)) {
         // Oops, we have a cut.
         hc->set_cv_type(n, HC_CUT);
       }
 
       n = hc->append_cv(HC_FREE, bz_segs[i+1]._v[0]);
-      hc->set_cv_in(n, 3.0 * (bz_segs[i]._v[3] - bz_segs[i]._v[2]) / scale_in);
+      hc->set_cv_in(n, 3.0f * (bz_segs[i]._v[3] - bz_segs[i]._v[2]) / scale_in);
       hc->set_cv_tstart(n, bz_segs[i]._t);
 
-      hc->set_cv_out(n, 3.0 * (bz_segs[i+1]._v[1] - bz_segs[i+1]._v[0]) / scale_out);
+      hc->set_cv_out(n, 3.0f * (bz_segs[i+1]._v[1] - bz_segs[i+1]._v[0]) / scale_out);
     }
 
     // Now the last CV.
     scale_in = scale_out;
     i = bz_segs.size()-1;
     n = hc->append_cv(HC_SMOOTH, bz_segs[i]._v[3]);
-    hc->set_cv_in(n, 3.0 * (bz_segs[i]._v[3] - bz_segs[i]._v[2]) / scale_in);
+    hc->set_cv_in(n, 3.0f * (bz_segs[i]._v[3] - bz_segs[i]._v[2]) / scale_in);
     hc->set_cv_tstart(n, bz_segs[i]._t);
   }
 
@@ -538,12 +541,12 @@ convert_to_hermite(HermiteCurve *hc) const {
       LVector3f in = hc->get_cv_in(n);
       LVector3f out = hc->get_cv_out(n);
 
-      if (in.almost_equal(out, 0.0001)) {
+      if (in.almost_equal(out, 0.0001f)) {
         hc->set_cv_type(n, HC_SMOOTH);
       } else {
         in.normalize();
         out.normalize();
-        if (in.almost_equal(out, 0.0001)) {
+        if (in.almost_equal(out, 0.0001f)) {
           hc->set_cv_type(n, HC_G1);
         }
       }
@@ -580,17 +583,17 @@ convert_to_nurbs(ParametricCurve *nc) const {
       nurbs->append_cv(bz_segs[i]._v[1]);
       nurbs->append_cv(bz_segs[i]._v[2]);
       if (i == (int)bz_segs.size()-1 ||
-          !bz_segs[i]._v[3].almost_equal(bz_segs[i+1]._v[0], 0.0001)) {
+          !bz_segs[i]._v[3].almost_equal(bz_segs[i+1]._v[0], 0.0001f)) {
         nurbs->append_cv(bz_segs[i]._v[3]);
       }
     }
 
     float t;
     int ki = 4;
-    nurbs->set_knot(0, 0.0);
-    nurbs->set_knot(1, 0.0);
-    nurbs->set_knot(2, 0.0);
-    nurbs->set_knot(3, 0.0);
+    nurbs->set_knot(0, 0.0f);
+    nurbs->set_knot(1, 0.0f);
+    nurbs->set_knot(2, 0.0f);
+    nurbs->set_knot(3, 0.0f);
 
     for (i = 0; i < (int)bz_segs.size(); i++) {
       t = bz_segs[i]._t;
@@ -599,8 +602,8 @@ convert_to_nurbs(ParametricCurve *nc) const {
       nurbs->set_knot(ki+1, t);
       nurbs->set_knot(ki+2, t);
       ki += 3;
-      if (i == (int)bz_segs.size()-1 ||
-          !bz_segs[i]._v[3].almost_equal(bz_segs[i+1]._v[0], 0.0001)) {
+      if (i == ((int)bz_segs.size())-1 ||
+          !bz_segs[i]._v[3].almost_equal(bz_segs[i+1]._v[0], 0.0001f)) {
         nurbs->set_knot(ki, t);
         ki++;
       }
@@ -743,13 +746,13 @@ format_egg(ostream &, const string &, const string &, int) const {
 float ParametricCurve::
 r_calc_length(float t1, float t2, const LPoint3f &p1, const LPoint3f &p2,
               float seglength) const {
-  static const float length_tolerance = 0.0000001;
-  static const float t_tolerance = 0.000001;
+  static const float length_tolerance = 0.0000001f;
+  static const float t_tolerance = 0.000001f;
 
   if (t2 - t1 < t_tolerance) {
     // Stop recursing--we've just walked off the limit for
     // representing smaller values of t.
-    return 0.0;
+    return 0.0f;
   } else {
     float tmid;
     LPoint3f pmid;
@@ -757,7 +760,7 @@ r_calc_length(float t1, float t2, const LPoint3f &p1, const LPoint3f &p2,
 
     // Calculate the point on the curve midway between the two
     // endpoints.
-    tmid = (t1+t2)/2.0;
+    tmid = (t1+t2)*0.5f;
     get_point(tmid, pmid);
 
     // Did we increase the length of the segment measurably?
@@ -792,8 +795,8 @@ r_find_length(float target_length, float &found_t,
               float t1, float t2,
               const LPoint3f &p1, const LPoint3f &p2,
               float &seglength) const {
-  static const float length_tolerance = 0.0000001;
-  static const float t_tolerance = 0.000001;
+  static const float length_tolerance = 0.0000001f;
+  static const float t_tolerance = 0.000001f;
 
   if (target_length < t_tolerance) {
     // Stop recursing--we've just walked off the limit for
@@ -808,7 +811,7 @@ r_find_length(float target_length, float &found_t,
 
     // Calculate the point on the curve midway between the two
     // endpoints.
-    tmid = (t1+t2)/2.0;
+    tmid = (t1+t2)*0.5f;
     get_point(tmid, pmid);
 
     // Did we increase the length of the segment measurably?

+ 1 - 1
panda/src/parametrics/parametricCurveCollection.I

@@ -58,7 +58,7 @@ get_curve(int index) const {
 INLINE float ParametricCurveCollection::
 get_max_t() const {
   if (_curves.empty()) {
-    return 0.0;
+    return 0.0f;
   }
   return _curves.back()->get_max_t();
 }

+ 24 - 21
panda/src/parametrics/parametricCurveCollection.cxx

@@ -337,7 +337,7 @@ make_even(float max_t, float segments_per_unit) {
   // approximately the same length as all the others.
   CurveFitter fitter;
 
-  int num_segments = max(1, (int)floor(segments_per_unit * xyz_curve->get_max_t() + 0.5));
+  int num_segments = max(1, (int)floor(segments_per_unit * xyz_curve->get_max_t() + 0.5f));
 
   if (parametrics_cat.is_debug()) {
     parametrics_cat.debug()
@@ -353,13 +353,16 @@ make_even(float max_t, float segments_per_unit) {
       << num_segments << " segments of " << segment_length << " units each.\n";
   }
 
-  float last_t = 0.0;
-  fitter.add_xyz(0.0, LVecBase3f(last_t, 0.0, 0.0));
+  float last_t = 0.0f;
+  fitter.add_xyz(0.0f, LVecBase3f(last_t, 0.0f, 0.0f));
+  float val_inc= 1.0f/(num_segments * max_t);
+  float val=val_inc;
 
-  for (int i = 0; i < num_segments; i++) {
+  for (int i = 0; i < num_segments; i++,val+=val_inc) {
     float next_t = xyz_curve->find_length(last_t, segment_length);
-    fitter.add_xyz((float)(i + 1) / num_segments * max_t,
-                   LVecBase3f(next_t, 0.0, 0.0));
+    fitter.add_xyz(/*(float)(i + 1)/(num_segments * max_t),*/
+                   val,
+                   LVecBase3f(next_t, 0.0f, 0.0f));
 
     if (parametrics_cat.is_spam()) {
       parametrics_cat.spam()
@@ -425,13 +428,13 @@ face_forward(float segments_per_unit) {
   float max_t = get_max_t();
   int num_segments = (int)floor(segments_per_unit * max_t + 0.5);
 
-  LVecBase3f hpr(0.0, 0.0, 0.0);
+  LVecBase3f hpr(0.0f, 0.0f, 0.0f);
 
   // We compute the first HPR point a little point into the beginning
-  // of the curve, instead of at 0.0, because the tangent at 0.0 is
+  // of the curve, instead of at 0.0f, because the tangent at 0.0f is
   // likely to be zero.
   determine_hpr(0.001, xyz_curve, hpr);
-  fitter.add_hpr(0.0, hpr);
+  fitter.add_hpr(0.0f, hpr);
 
   for (int i = 0; i < num_segments; i++) {
     float t = (float)(i + 1) / num_segments * max_t;
@@ -462,10 +465,10 @@ reset_max_t(float max_t) {
   PT(NurbsCurve) nurbs = new NurbsCurve;
   nurbs->set_curve_type(PCT_T);
   nurbs->set_order(2);
-  nurbs->append_cv(LVecBase3f(0.0, 0.0, 0.0));
-  nurbs->append_cv(LVecBase3f(get_max_t(), 0.0, 0.0));
-  nurbs->set_knot(0, 0.0);
-  nurbs->set_knot(1, 0.0);
+  nurbs->append_cv(LVecBase3f(0.0f, 0.0f, 0.0f));
+  nurbs->append_cv(LVecBase3f(get_max_t(), 0.0f, 0.0f));
+  nurbs->set_knot(0, 0.0f);
+  nurbs->set_knot(1, 0.0f);
   nurbs->set_knot(2, max_t);
   nurbs->set_knot(3, max_t);
   nurbs->recompute();
@@ -560,14 +563,14 @@ evaluate(float t, LVecBase3f &xyz, LVecBase3f &hpr) const {
 ////////////////////////////////////////////////////////////////////
 bool ParametricCurveCollection::
 evaluate(float t, LMatrix4f &result, CoordinateSystem cs) const {
-  LVecBase3f xyz(0.0, 0.0, 0.0);
-  LVecBase3f hpr(0.0, 0.0, 0.0);
+  LVecBase3f xyz(0.0f, 0.0f, 0.0f);
+  LVecBase3f hpr(0.0f, 0.0f, 0.0f);
 
   if (!evaluate(t, xyz, hpr)) {
     return false;
   }
 
-  compose_matrix(result, LVecBase3f(1.0, 1.0, 1.0), hpr, xyz, cs);
+  compose_matrix(result, LVecBase3f(1.0f, 1.0f, 1.0f), hpr, xyz, cs);
   return true;
 }
 
@@ -576,7 +579,7 @@ evaluate(float t, LMatrix4f &result, CoordinateSystem cs) const {
 //       Access: Published
 //  Description: Determines the value of t that should be passed to
 //               the XYZ and HPR curves, after applying the given
-//               value of t to all the timewarps.  Return -1.0 if the
+//               value of t to all the timewarps.  Return -1.0f if the
 //               value of t exceeds one of the timewarps' ranges.
 ////////////////////////////////////////////////////////////////////
 float ParametricCurveCollection::
@@ -590,7 +593,7 @@ evaluate_t(float t) const {
 
     if (curve->get_curve_type() == PCT_T) {
       if (!curve->get_point(t0, point)) {
-        return -1.0;
+        return -1.0f;
       }
       t0 = point[0];
     }
@@ -615,7 +618,7 @@ adjust_xyz(float t, const LVecBase3f &xyz) {
   }
 
   float t0 = evaluate_t(t);
-  if (t0 >= 0.0 && t < xyz_curve->get_max_t()) {
+  if (t0 >= 0.0f && t < xyz_curve->get_max_t()) {
     return xyz_curve->adjust_point(t, xyz[0], xyz[1], xyz[2]);
   }
   return false;
@@ -637,7 +640,7 @@ adjust_hpr(float t, const LVecBase3f &hpr) {
   }
 
   float t0 = evaluate_t(t);
-  if (t0 >= 0.0 && t < hpr_curve->get_max_t()) {
+  if (t0 >= 0.0f && t < hpr_curve->get_max_t()) {
     return hpr_curve->adjust_point(t, hpr[0], hpr[1], hpr[2]);
   }
   return false;
@@ -927,7 +930,7 @@ determine_hpr(float t, ParametricCurve *xyz_curve, LVecBase3f &hpr) const {
     return false;
   }
 
-  if (tangent.length_squared() == 0.0) {
+  if (tangent.length_squared() == 0.0f) {
     return false;
   }
 

+ 1 - 1
panda/src/parametrics/parametricCurveDrawer.I

@@ -25,7 +25,7 @@
 INLINE float ParametricCurveDrawer::
 get_max_t() const {
   if (_curves == (ParametricCurveCollection *)NULL) {
-    return 0.0;
+    return 0.0f;
   } else {
     return _curves->get_max_t();
   }

+ 8 - 8
panda/src/parametrics/parametricCurveDrawer.cxx

@@ -34,11 +34,11 @@ TypeHandle ParametricCurveDrawer::_type_handle;
 ////////////////////////////////////////////////////////////////////
 ParametricCurveDrawer::
 ParametricCurveDrawer() {
-  _lines.set_color(1.0, 1.0, 1.0);
-  _ticks.set_color(1.0, 0.0, 0.0);
+  _lines.set_color(1.0f, 1.0f, 1.0f);
+  _ticks.set_color(1.0f, 0.0f, 0.0f);
   _tick_scale = 0.1;
   _num_segs = 100.0;
-  _num_ticks = 0.0;
+  _num_ticks = 0.0f;
   _frame_accurate = false;
   _geom_node = new GeomNode;
   _drawn = false;
@@ -357,7 +357,7 @@ draw() {
   scale = max_t / (float)(total_segs-1);
 
   // Now draw the time tick marks.
-  if (_num_ticks > 0.0) {
+  if (_num_ticks > 0.0f) {
     int total_ticks = (int)floor(max_t * _num_ticks + 0.5);
     ParametricCurve *xyz_curve = _curves->get_default_curve();
     ParametricCurve *hpr_curve = _curves->get_hpr_curve();
@@ -384,7 +384,7 @@ draw() {
           NodeRelation *arc = new RenderRelation(_geom_node, _tick_geometry);
           _tick_arcs.push_back(arc);
 
-          LVecBase3f hpr(0.0, 0.0, 0.0);
+          LVecBase3f hpr(0.0f, 0.0f, 0.0f);
           if (hpr_curve != (ParametricCurve *)NULL) {
             hpr_curve->get_point(t0, hpr);
           }
@@ -462,15 +462,15 @@ get_tick_marks(const LVecBase3f &tangent, LVecBase3f &t1, LVecBase3f &t2) {
   // unit vector.
   if (fabs(tn[0]) <= fabs(tn[1]) && fabs(tn[0]) <= fabs(tn[2])) {
     // X is smallest.
-    t1 = tn.cross(LVector3f(1.0, 0.0, 0.0));
+    t1 = tn.cross(LVector3f(1.0f, 0.0f, 0.0f));
 
   } else if (fabs(tn[1]) <= fabs(tn[2])) {
     // Y is smallest.
-    t1 = tn.cross(LVector3f(0.0, 1.0, 0.0));
+    t1 = tn.cross(LVector3f(0.0f, 1.0f, 0.0f));
 
   } else {
     // Z is smallest.
-    t1 = tn.cross(LVector3f(0.0, 0.0, 1.0));
+    t1 = tn.cross(LVector3f(0.0f, 0.0f, 1.0f));
   }
 
   t2 = tn.cross(t1);

+ 20 - 20
panda/src/parametrics/piecewiseCurve.cxx

@@ -64,12 +64,12 @@ is_valid() const {
 //     Function: PiecewiseCurve::get_max_t
 //       Access: Published, Virtual
 //  Description: Returns the upper bound of t for the entire curve.
-//               The curve is defined in the range 0.0 <= t <=
+//               The curve is defined in the range 0.0f <= t <=
 //               get_max_t().
 ////////////////////////////////////////////////////////////////////
 float PiecewiseCurve::
 get_max_t() const {
-  return _segs.empty() ? 0.0 : _segs.back()._tend;
+  return _segs.empty() ? 0.0f : _segs.back()._tend;
 }
 
 
@@ -77,7 +77,7 @@ get_max_t() const {
 //     Function: PiecewiseCurve::get_point
 //       Access: Published, Virtual
 //  Description: Returns the point of the curve at a given parametric
-//               point t.  Returns true if t is in the valid range 0.0
+//               point t.  Returns true if t is in the valid range 0.0f
 //               <= t <= get_max_t(); if t is outside this range, sets
 //               point to the value of the curve at the beginning or
 //               end (whichever is nearer) and returns false.
@@ -147,10 +147,10 @@ adjust_point(float t,
     return false;
   }
 
-  rebuild_curveseg(RT_CV | RT_KEEP_ORIG, 0.0, LVecBase4f(),
-                   RT_POINT, t, LVecBase4f(px, py, pz, 1.0),
+  rebuild_curveseg(RT_CV | RT_KEEP_ORIG, 0.0f, LVecBase4f(),
+                   RT_POINT, t, LVecBase4f(px, py, pz, 1.0f),
                    RT_TANGENT | RT_KEEP_ORIG, t, LVecBase4f(),
-                   RT_CV | RT_KEEP_ORIG, 0.0, LVecBase4f());
+                   RT_CV | RT_KEEP_ORIG, 0.0f, LVecBase4f());
   return true;
 }
 
@@ -172,10 +172,10 @@ adjust_tangent(float t,
     return false;
   }
 
-  rebuild_curveseg(RT_CV | RT_KEEP_ORIG, 0.0, LVecBase4f(),
+  rebuild_curveseg(RT_CV | RT_KEEP_ORIG, 0.0f, LVecBase4f(),
                    RT_POINT | RT_KEEP_ORIG, t, LVecBase4f(),
-                   RT_TANGENT, t, LVecBase4f(tx, ty, tz, 0.0),
-                   RT_CV | RT_KEEP_ORIG, 0.0, LVecBase4f());
+                   RT_TANGENT, t, LVecBase4f(tx, ty, tz, 0.0f),
+                   RT_CV | RT_KEEP_ORIG, 0.0f, LVecBase4f());
   return true;
 }
 
@@ -197,10 +197,10 @@ adjust_pt(float t,
     return false;
   }
 
-  rebuild_curveseg(RT_CV | RT_KEEP_ORIG, 0.0, LVecBase4f(),
-                   RT_POINT, t, LVecBase4f(px, py, pz, 1.0),
-                   RT_TANGENT, t, LVecBase4f(tx, ty, tz, 0.0),
-                   RT_CV | RT_KEEP_ORIG, 0.0, LVecBase4f());
+  rebuild_curveseg(RT_CV | RT_KEEP_ORIG, 0.0f, LVecBase4f(),
+                   RT_POINT, t, LVecBase4f(px, py, pz, 1.0f),
+                   RT_TANGENT, t, LVecBase4f(tx, ty, tz, 0.0f),
+                   RT_CV | RT_KEEP_ORIG, 0.0f, LVecBase4f());
   return true;
 }
 
@@ -339,7 +339,7 @@ get_tlength(int ti) const {
 float PiecewiseCurve::
 get_tstart(int ti) const {
   assert(ti >= 0 && ti <= (int)_segs.size());
-  return (ti==0) ? 0.0 : _segs[ti-1]._tend;
+  return (ti==0) ? 0.0f : _segs[ti-1]._tend;
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -482,7 +482,7 @@ find_curve(const ParametricCurve *&curve, float &t) const {
 
   int ti;
   for (ti = _last_ti; ti < (int)_segs.size(); ti++) {
-    if (_segs[ti]._tend+0.00001 > t) {
+    if (_segs[ti]._tend+0.00001f > t) {
       break;
     }
   }
@@ -499,7 +499,7 @@ find_curve(const ParametricCurve *&curve, float &t) const {
   if (t < 0) {
     // Oops.
     curve = _segs[0]._curve;
-    t = 0.0;
+    t = 0.0f;
     return false;
   }
 
@@ -510,19 +510,19 @@ find_curve(const ParametricCurve *&curve, float &t) const {
     // screwed.  There's one exception: if we were right on a border between
     // curves, try the curve before.
 
-    if (ti > 0 && t < _segs[ti-1]._tend+0.0001) {
+    if (ti > 0 && t < _segs[ti-1]._tend+0.0001f) {
       ti--;
-      t = 1.0;
+      t = 1.0f;
     }
 
     if (ti >= (int)_segs.size()) {
       if (_segs.empty()) {
         curve = NULL;
-        t = 0.0;
+        t = 0.0f;
         return false;
       } else {
         curve = _segs.back()._curve;
-        t = 1.0;
+        t = 1.0f;
         return false;
       }
     } else if (!_segs[ti]._curve->is_valid()) {

+ 1 - 1
panda/src/pgui/pgEntry.cxx

@@ -716,7 +716,7 @@ update_cursor() {
   } else {
     double elapsed_time = 
       ClockObject::get_global_clock()->get_frame_time() - _blink_start;
-    int cycle = (int)floor(elapsed_time * _blink_rate * 2.0);
+    int cycle = (int)(elapsed_time * _blink_rate * 2.0f);
     bool visible = ((cycle & 1) == 0);
     show_hide_cursor(visible);
   }

+ 7 - 5
panda/src/pnmimage/pnm-image-filter.cxx

@@ -123,7 +123,7 @@ filter_row(StoreType dest[], int dest_len,
   // Similarly, if we are expanding the row, we want to start the new row at
   // the far left edge of the original pixel, not in the center.  So we will
   // have a non-zero offset.
-  int offset = (int)floor(iscale/2.0);
+  int offset = (int)floor(iscale*0.5);
 
   for (int dest_x=0; dest_x<dest_len; dest_x++) {
     double center = (dest_x-offset)/scale;
@@ -487,12 +487,12 @@ box_filter_line(const PNMImage &image,
                 double x0, int y, double x1, double y_contrib,
                 double &red, double &grn, double &blu, double &alpha,
                 double &pixel_count) {
-  int x = (int)floor(x0);
+  int x = (int)x0;
   // Get the first (partial) xel
   box_filter_xel(image, x, y, (double)(x+1)-x0, y_contrib,
                  red, grn, blu, alpha, pixel_count);
 
-  int x_last = (int)floor(x1);
+  int x_last = (int)x1;
   if (x < x_last) {
     x++;
     while (x < x_last) {
@@ -518,12 +518,14 @@ box_filter_region(const PNMImage &image,
   double red = 0.0, grn = 0.0, blu = 0.0, alpha = 0.0;
   double pixel_count = 0.0;
 
-  int y = (int)floor(y0);
+  assert(y0 >=0 && y1 >=0);
+
+  int y = (int)y0;
   // Get the first (partial) row
   box_filter_line(image, x0, y, x1, (double)(y+1)-y0,
                   red, grn, blu, alpha, pixel_count);
 
-  int y_last = (int)floor(y1);
+  int y_last = (int)y1;
   if (y < y_last) {
     y++;
     while (y < y_last) {