From 6457b8b80be65742e0dea18ddce1e8abfb54ae29 Mon Sep 17 00:00:00 2001 From: Nick Fisher Date: Fri, 22 Sep 2023 08:20:36 +0800 Subject: [PATCH] remove old FFI references from FilamentController --- lib/filament_controller.dart | 65 ++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 37 deletions(-) diff --git a/lib/filament_controller.dart b/lib/filament_controller.dart index f5b033b8..fb611e7b 100644 --- a/lib/filament_controller.dart +++ b/lib/filament_controller.dart @@ -1,10 +1,5 @@ import 'dart:async'; -import 'dart:ffi'; - import 'dart:ui' as ui; - -import 'package:ffi/ffi.dart'; - import 'package:flutter/services.dart'; import 'package:polyvox_filament/animations/bone_animation_data.dart'; import 'package:polyvox_filament/animations/morph_animation_data.dart'; @@ -380,36 +375,36 @@ class FilamentController { if (_viewer == null || _resizing) { throw Exception("No viewer available, ignoring"); } - var data = calloc(animation.frameData.length); - int offset = 0; - var numFrames = animation.frameData.length ~/ 7; - var boneNames = calloc>(1); - boneNames.elementAt(0).value = - animation.boneName.toNativeUtf8().cast(); + // var data = calloc(animation.frameData.length); + // int offset = 0; + // var numFrames = animation.frameData.length ~/ 7; + // var boneNames = calloc>(1); + // boneNames.elementAt(0).value = + // animation.boneName.toNativeUtf8().cast(); - var meshNames = calloc>(animation.meshNames.length); - for (int i = 0; i < animation.meshNames.length; i++) { - meshNames.elementAt(i).value = - animation.meshNames[i].toNativeUtf8().cast(); - } + // var meshNames = calloc>(animation.meshNames.length); + // for (int i = 0; i < animation.meshNames.length; i++) { + // meshNames.elementAt(i).value = + // animation.meshNames[i].toNativeUtf8().cast(); + // } - for (int i = 0; i < animation.frameData.length; i++) { - data.elementAt(offset).value = animation.frameData[i]; - offset += 1; - } + // for (int i = 0; i < animation.frameData.length; i++) { + // data.elementAt(offset).value = animation.frameData[i]; + // offset += 1; + // } - await _channel.invokeMethod("setBoneAnimation", [ - _assetManager, - asset, - data, - numFrames, - 1, - boneNames, - meshNames, - animation.meshNames.length, - animation.frameLengthInMs - ]); - calloc.free(data); + // await _channel.invokeMethod("setBoneAnimation", [ + // _assetManager, + // asset, + // data, + // numFrames, + // 1, + // boneNames, + // meshNames, + // animation.meshNames.length, + // animation.frameLengthInMs + // ]); + // calloc.free(data); } Future removeAsset(FilamentEntity asset) async { @@ -545,11 +540,7 @@ class FilamentController { throw Exception("No viewer available, ignoring"); } assert(matrix.length == 16); - var ptr = calloc(16); - for (int i = 0; i < 16; i++) { - ptr.elementAt(i).value = matrix[i]; - } - await _channel.invokeMethod("setCameraModelMatrix", [ptr]); + await _channel.invokeMethod("setCameraModelMatrix", matrix); } Future setTexture(FilamentEntity asset, String assetPath,