Quantcast
Channel: Daz Script Developer Discussion - Daz 3D Forums
Viewing all articles
Browse latest Browse all 1067

[HORRENDOUS BUG] property.getValue(DzTime) doesn't work with DzTime

$
0
0
  1. Load figure
  2. Select any bone
  3. Key ZRotate = 0 on frame 0
  4. Key ZRotate = 7 on frame 5 (or any non-zero value on any other frame)
  5. Run the following script

 print("key\ttime\tvalue");

var property = bones[0].findProperty("ZRotate");

for (var i=0; i < property.getNumKeys(); i++) {

      var time = property.getKeyTime(i);

      var val = property.getValue(time);

      print("%1\t%2\t%3".arg(i).arg(time.valueOf()).arg(val));

}

The output will blow your mind. The script thinks the property is zero on frame 5 when you can see with your own eyes it is 7. I have just spent half a day debugging only to discover to my astonishment the following horrendous API bug ...

DzTime DzProperty.getTime(int index) takes a key index (int between 0 and property.getNumKeys()) and returns a DzTime.

Number DzProperty.getValue(DzTime time) takes a DzTime and returns the property value at that time. The problem is this function does not work with DzTime but with an int and because DzTime doesn't autocast to an int (only the good Lord himself could explain why), the function fails and returns the property value for frame 0. See http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/property_dz&nbsp; and http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/floatproperty_dz

The solution?

 var time = property.getKeyTime(i) + 0;

This forces DzTime to autocast to an int which then allows getValue(int) to work correctly. What a shambles.

 


Viewing all articles
Browse latest Browse all 1067

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>