Serialize model transform as 16-bit floats

main
copygirl 3 weeks ago
parent 9052c473ef
commit 0cd92b8010
  1. 8
      sync_controller.gd

@ -76,7 +76,8 @@ func sync_model_animation(
var uncompressed_buffer := buffer.decompress(uncompressed_length, FileAccess.COMPRESSION_ZSTD); var uncompressed_buffer := buffer.decompress(uncompressed_length, FileAccess.COMPRESSION_ZSTD);
var stream := StreamBuffer.from_buffer(uncompressed_buffer) var stream := StreamBuffer.from_buffer(uncompressed_buffer)
model.transform = stream.read_transform32()
model.transform = stream.read_transform16()
# We skipped some bones, so reset the skipped ones to the rest pose. # We skipped some bones, so reset the skipped ones to the rest pose.
var all_bones := {} var all_bones := {}
@ -114,7 +115,7 @@ static func send_model_animation(module: copyMultiplayer) -> void:
var media_pipe = module.get_node("../MediaPipeController") var media_pipe = module.get_node("../MediaPipeController")
if (not model) or (not skeleton) or (not media_pipe): return if (not model) or (not skeleton) or (not media_pipe): return
write_stream.write_transform32(model.transform) write_stream.write_transform16(model.transform)
# Pre-filter any bones that are in rest pose. # Pre-filter any bones that are in rest pose.
var restless_bones := {} var restless_bones := {}
@ -127,9 +128,8 @@ static func send_model_animation(module: copyMultiplayer) -> void:
write_stream.write_uint8(restless_bones.size()) write_stream.write_uint8(restless_bones.size())
for bone_name in restless_bones: for bone_name in restless_bones:
var bone_pose: Transform3D = restless_bones[bone_name]
write_stream.write_uint8(module.bone_to_lookup[bone_name]) write_stream.write_uint8(module.bone_to_lookup[bone_name])
write_stream.write_bone_pose(bone_pose) write_stream.write_bone_pose(restless_bones[bone_name])
# TODO: Only write non-default blendshapes. Anything missing = default. # TODO: Only write non-default blendshapes. Anything missing = default.
var shape_dict: Dictionary = media_pipe.blend_shape_last_values var shape_dict: Dictionary = media_pipe.blend_shape_last_values

Loading…
Cancel
Save