John Denker wrote:
 > Ron Jensen wrote:
 > > The <step> tag effectively truncates the property, 29.919999999999
 > > becomes 29.91, so a (3D) readout reads off one number.
 > >
 > > I am proposing an new tag, <bias>, that will act like <offset> but be
 > > applied before <step> and <scroll>
 >
 > While the <bias> tag seems reasonable enough, the *first* step
 > should be to repair the <step> feature so that it performs
 > rounding rather than truncation.

This subject came up on the IRC channel (which increasingly seems like
the only contact I have with you guys -- I'm not dead, really!) and
Ron sent me his bias patch for commit.

The patch itself looks sane and easy.  But I think I agree with John,
this is a workaround for a design flaw in the step animation that we
should just fix.  Can someone (ideally people who, unlike me, know
where to look for lots of step animations) try this completely
untested patch to simgear/scene/model/animation.cxx?  It just
rewrites apply_mods() to do rounding (and IMHO to be clearer and
simpler):

--- simgear/scene/model/animation.cxx   2 Feb 2007 07:00:54 -0000       1.63
+++ simgear/scene/model/animation.cxx   7 Feb 2007 18:18:32 -0000
@@ -107,27 +107,14 @@
  static double
  apply_mods(double property, double step, double scroll)
  {
-
-  double modprop;
-  if(step > 0) {
-    double scrollval = 0.0;
-    if(scroll > 0) {
-      // calculate scroll amount (for odometer like movement)
-      double remainder  =  step - fmod(fabs(property), step);
-      if (remainder < scroll) {
-        scrollval = (scroll - remainder) / scroll * step;
-      }
-    }
-  // apply stepping of input value
-  if(property > 0)
-     modprop = ((floor(property/step) * step) + scrollval);
-  else
-     modprop = ((ceil(property/step) * step) + scrollval);
-  } else {
-     modprop = property;
-  }
-  return modprop;
-
+    if(step == 0)
+        return property;
+    double bias = (property > 0) ? 0.5 : -0.5;
+    double result = step * (int)(bias + (property / step));
+    double diff = result - property;
+    if(fabs(diff) < scroll)
+        result = property + step * (diff / scroll);
+    return result;
  }


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to