diff --git a/panda/src/parametrics/curve.cxx b/panda/src/parametrics/curve.cxx index b41a8519c6..2b7cec7e67 100644 --- a/panda/src/parametrics/curve.cxx +++ b/panda/src/parametrics/curve.cxx @@ -261,6 +261,80 @@ compute_t(double start_t, double length_offset, double guess, return guess; } +//////////////////////////////////////////////////////////////////// +// Function: ParametricCurve::convert_to_hermite +// Access: Public, Scheme +// Description: Stores an equivalent curve representation in the +// indicated Hermite curve, if possible. Returns true +// if successful, false otherwise. +//////////////////////////////////////////////////////////////////// +bool ParametricCurve:: +convert_to_hermite(HermiteCurve &hc) const { +#if 0 //[////todo:skyler + BezierSegs bz_segs; + if (!GetBezierSegs(bz_segs)) { + return false; + } + + // Now convert the Bezier segments to a Hermite. Normally, the + // Beziers will match up head-to-tail, but if they don't, that's a + // cut. + hc.remove_all_cvs(); + hc.set_curve_type(_curve_type); + + int i, n; + if (!bz_segs.empty()) { + double scale_in = 0.0; + double 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); + + for (i = 0; i < 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].almostEqual(bz_segs[i+1]._v[0], 0.0001)) { + // 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_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); + } + + // 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_tstart(n, bz_segs[i]._t); + } + + // Finally, go through and figure out which CV's are smooth or G1. + int num_cvs = hc.get_num_cvs(); + for (n = 1; n < num_cvs-1; n++) { + if (hc.get_cv_type(n)!=HC_CUT) { + pfVec3 in = hc.get_cv_in(n); + pfVec3 out = hc.get_cv_out(n); + + if (in.almostEqual(out, 0.0001)) { + hc.set_cv_type(n, HC_SMOOTH); + } else { + in.normalize(); + out.normalize(); + if (in.almostEqual(out, 0.0001)) { + hc.set_cv_type(n, HC_G1); + } + } + } + } +#endif //] + return true; +} + //////////////////////////////////////////////////////////////////// // Function: ParametricCurve::convert_to_nurbs // Access: Public diff --git a/panda/src/parametrics/hermiteCurve.cxx b/panda/src/parametrics/hermiteCurve.cxx index e9dca25783..839607f52a 100644 --- a/panda/src/parametrics/hermiteCurve.cxx +++ b/panda/src/parametrics/hermiteCurve.cxx @@ -899,6 +899,7 @@ wrap_hpr(const LVector3f &hpr1, LVector3f &hpr2) { //////////////////////////////////////////////////////////////////// void HermiteCurve:: invalidate_cv(int n, bool redo_all) { +#if 0 //[////todo:skyler double t1 = 0.0, t2 = get_max_t(); if (n>0 && _points[n-1]._type!=HC_CUT) { const HermiteCurveCV &p1 = _points[n-1]; @@ -933,6 +934,7 @@ invalidate_cv(int n, bool redo_all) { invalidate(t1, t2); } } +#endif //] } @@ -968,6 +970,7 @@ find_cv(double t) { //////////////////////////////////////////////////////////////////// void HermiteCurve:: recompute_basis() { +#if 0 //[////todo:skyler int n; for (n = 0; n<_segs.size(); n++) { if (_points[n]._type==HC_CUT) { @@ -983,5 +986,6 @@ recompute_basis() { get_curveseg(n)->hermite_basis(p1, p2, get_tlength(n)); } } +#endif //] }