[Bf-extensions-cvs] [7dec026] master: FBX: more minor tweaks (main here is making uids shorters, easier to read in JSONed version of files).

Bastien Montagne noreply at git.blender.org
Tue Apr 1 21:50:43 CEST 2014


Commit: 7dec02601e1b010796b0ffad0d8a285b704d9f82
Author: Bastien Montagne
Date:   Tue Apr 1 09:55:33 2014 +0200
https://developer.blender.org/rBA7dec02601e1b010796b0ffad0d8a285b704d9f82

FBX: more minor tweaks (main here is making uids shorters, easier to read in JSONed version of files).

===================================================================

M	io_scene_fbx/export_fbx_bin.py

===================================================================

diff --git a/io_scene_fbx/export_fbx_bin.py b/io_scene_fbx/export_fbx_bin.py
index fd94319..cf628f1 100644
--- a/io_scene_fbx/export_fbx_bin.py
+++ b/io_scene_fbx/export_fbx_bin.py
@@ -183,6 +183,11 @@ def _key_to_uid(uids, key):
             uid = -uid
         if uid >= 2**63:
             uid //= 2
+    # Try to make our uid shorter!
+    if uid > int(1e9):
+        t_uid = uid % int(1e9)
+        if t_uid not in uids:
+            uid = t_uid
     # Make sure our uid *is* unique.
     if uid in uids:
         inc = 1 if uid < 2**62 else -1
@@ -1799,6 +1804,7 @@ def fbx_data_animation_elements(root, scene_data):
         return (int(v) for v in units_convert_iter((f / fps for f, _v in keys), "second", "ktime"))
 
     astack_key, alayers = animations
+    astack_tmpl = scene_data.templates[b"AnimationStack"]
     acn_tmpl = scene_data.templates[b"AnimationCurveNode"]
 
     # Animation stack.
@@ -1806,6 +1812,16 @@ def fbx_data_animation_elements(root, scene_data):
     astack.add_string(fbx_name_class(scene.name.encode(), b"AnimStack"))
     astack.add_string(b"")
 
+    astack_props = elem_properties(astack)
+    r = scene_data.scene.render
+    fps = r.fps / r.fps_base
+    f_start = int(units_convert(scene_data.scene.frame_start / fps, "second", "ktime"))
+    f_end = int(units_convert(scene_data.scene.frame_end / fps, "second", "ktime"))
+    elem_props_set(astack_props, "p_timestamp", b"LocalStart", f_start)
+    elem_props_set(astack_props, "p_timestamp", b"LocalStop", f_end)
+    elem_props_set(astack_props, "p_timestamp", b"ReferenceStart", f_start)
+    elem_props_set(astack_props, "p_timestamp", b"ReferenceStop", f_end)
+
     for obj, (alayer_key, acurvenodes) in alayers.items():
         # Animation layer.
         alayer = elem_data_single_int64(root, b"AnimationLayer", get_fbxuid_from_key(alayer_key))
@@ -1982,8 +1998,6 @@ def fbx_animations_simplify(scene_data, animdata):
         p_currframe, p_key, p_key_write = keys[0]
         p_keyed = [(p_currframe - max_frame_diff, val) for val in p_key]
         for currframe, key, key_write in keys:
-            #if obj.name == "Cube":
-                #print(currframe, key, key_write)
             for idx, (val, p_val) in enumerate(zip(key, p_key)):
                 p_keyedframe, p_keyedval = p_keyed[idx]
                 if val == p_val:
@@ -2455,10 +2469,10 @@ def fbx_header_elements(root, scene_data, time=None):
     f_start = scene_data.scene.frame_start
     f_end = scene_data.scene.frame_end
     elem_props_set(props, "p_enum", b"TimeMode", 14)  # FPS, 14 = custom...
-    elem_props_set(props, "p_timestamp", b"TimeSpanStart", int(units_convert(f_start / fps, "second", "ktime")))
-    elem_props_set(props, "p_timestamp", b"TimeSpanStop", int(units_convert(f_end / fps, "second", "ktime")))
-    #elem_props_set(props, "p_timestamp", b"TimeSpanStart", 0)
-    #elem_props_set(props, "p_timestamp", b"TimeSpanStop", FBX_KTIME)
+    #elem_props_set(props, "p_timestamp", b"TimeSpanStart", int(units_convert(f_start / fps, "second", "ktime")))
+    #elem_props_set(props, "p_timestamp", b"TimeSpanStop", int(units_convert(f_end / fps, "second", "ktime")))
+    elem_props_set(props, "p_timestamp", b"TimeSpanStart", 0)
+    elem_props_set(props, "p_timestamp", b"TimeSpanStop", FBX_KTIME)
     elem_props_set(props, "p_double", b"CustomFrameRate", fps)
 
     ##### End of GlobalSettings element.



More information about the Bf-extensions-cvs mailing list