diff --git a/thermion_dart/lib/src/bindings/src/thermion_dart_js_interop.g.dart b/thermion_dart/lib/src/bindings/src/thermion_dart_js_interop.g.dart index 7e064294..ecb2dd1f 100644 --- a/thermion_dart/lib/src/bindings/src/thermion_dart_js_interop.g.dart +++ b/thermion_dart/lib/src/bindings/src/thermion_dart_js_interop.g.dart @@ -257,7 +257,8 @@ sealed class Struct extends NativeType { return double4x4(arr1, arr2, arr3, arr4, ptr) as T; case TFogOptions: final ptr = TFogOptions.stackAlloc(); - return ptr.toDart() as T; + final fogOptions = ptr.toDart(); + return fogOptions as T; } throw Exception(); } @@ -590,10 +591,9 @@ extension type NativeLibrary(JSObject _) implements JSObject { Pointer out, ); external Pointer _GltfAssetLoader_create( - Pointer tEngine, - Pointer tMaterialProvider, - self.Pointer tNameComponentManager - ); + Pointer tEngine, + Pointer tMaterialProvider, + self.Pointer tNameComponentManager); external Pointer _GltfAssetLoader_load( Pointer tEngine, Pointer tAssetLoader, @@ -747,13 +747,12 @@ extension type NativeLibrary(JSObject _) implements JSObject { int format, ); external int _Texture_loadImage( - Pointer tEngine, - Pointer tTexture, - Pointer tImage, - int bufferFormat, - int pixelDataType, - int level - ); + Pointer tEngine, + Pointer tTexture, + Pointer tImage, + int bufferFormat, + int pixelDataType, + int level); external int _Texture_setImage( Pointer tEngine, Pointer tTexture, @@ -794,9 +793,7 @@ extension type NativeLibrary(JSObject _) implements JSObject { int level, ); external void _Texture_generateMipMaps( - Pointer tTexture, - Pointer tEngine - ); + Pointer tTexture, Pointer tEngine); external int _Texture_getDepth( Pointer tTexture, int level, @@ -811,11 +808,7 @@ extension type NativeLibrary(JSObject _) implements JSObject { int channel, ); external Pointer _Image_decode( - Pointer data, - size_t length, - Pointer name, - bool alpha - ); + Pointer data, size_t length, Pointer name, bool alpha); external Pointer _Image_getBytes( Pointer tLinearImage, ); @@ -2653,12 +2646,11 @@ void FilamentAsset_getEntities( } self.Pointer GltfAssetLoader_create( - self.Pointer tEngine, - self.Pointer tMaterialProvider, - self.Pointer tNameComponentManager -) { - final result = - _lib._GltfAssetLoader_create(tEngine.cast(), tMaterialProvider.cast(), tNameComponentManager.cast()); + self.Pointer tEngine, + self.Pointer tMaterialProvider, + self.Pointer tNameComponentManager) { + final result = _lib._GltfAssetLoader_create( + tEngine.cast(), tMaterialProvider.cast(), tNameComponentManager.cast()); return self.Pointer(result); } @@ -2908,9 +2900,10 @@ void View_setFrontFaceWindingInverted( void View_setFogOptions( self.Pointer tView, - self.Pointer tFogOptions, + TFogOptions tFogOptions, ) { - final result = _lib._View_setFogOptions(tView.cast(), tFogOptions.cast()); + final tFogOptionsPtr = tFogOptions._address; + final result = _lib._View_setFogOptions(tView.cast(), tFogOptionsPtr.cast()); return result; } @@ -3085,12 +3078,8 @@ self.Pointer Image_createEmpty( return self.Pointer(result); } -self.Pointer Image_decode( - self.Pointer data, - Dart__darwin_size_t length, - self.Pointer name, - bool alpha -) { +self.Pointer Image_decode(self.Pointer data, + Dart__darwin_size_t length, self.Pointer name, bool alpha) { final result = _lib._Image_decode(data, length, name, alpha); return self.Pointer(result); } @@ -4145,14 +4134,15 @@ void AnimationManager_createRenderThread( } void AnimationManager_resetToResetPoseRenderThread( - self.Pointer tAnimationManager, - self.Pointer tSceneAsset, - int requestId, - VoidCallback onComplete, - ) { - final result = _lib._AnimationManager_resetToRestPoseRenderThread(tAnimationManager, tSceneAsset, requestId, onComplete); + self.Pointer tAnimationManager, + self.Pointer tSceneAsset, + int requestId, + VoidCallback onComplete, +) { + final result = _lib._AnimationManager_resetToRestPoseRenderThread( + tAnimationManager, tSceneAsset, requestId, onComplete); return result; - } +} void Engine_createRenderThread( int backend, @@ -4383,7 +4373,8 @@ void Texture_generateMipMapsRenderThread( int requestId, DartVoidCallback onComplete, ) { - final result = _lib._Texture_generateMipMapsRenderThread(tTexture.cast(), tEngine.cast(), requestId, onComplete); + final result = _lib._Texture_generateMipMapsRenderThread( + tTexture.cast(), tEngine.cast(), requestId, onComplete); return result; } @@ -4882,8 +4873,8 @@ void Image_decodeRenderThread( self.Pointer)>> onComplete, ) { - final result = - _lib._Image_decodeRenderThread(data, length, name, alpha, onComplete.cast()); + final result = _lib._Image_decodeRenderThread( + data, length, name, alpha, onComplete.cast()); return result; } @@ -5239,8 +5230,8 @@ void GltfAssetLoader_createRenderThread( self.Pointer)>> callback, ) { - final result = _lib._GltfAssetLoader_createRenderThread( - tEngine.cast(), tMaterialProvider.cast(), tNameComponentManager.cast(), callback.cast()); + final result = _lib._GltfAssetLoader_createRenderThread(tEngine.cast(), + tMaterialProvider.cast(), tNameComponentManager.cast(), callback.cast()); return result; } @@ -6422,158 +6413,131 @@ final class TScene extends self.Struct { /// Copied from FogOptions in View.h extension TFogOptionsExt on Pointer { TFogOptions toDart() { - var distance = _lib.getValue(this + 0, "float").toDartDouble; - var cutOffDistance = _lib.getValue(this + 4, "float").toDartDouble; - var maximumOpacity = _lib.getValue(this + 8, "float").toDartDouble; - var height = _lib.getValue(this + 12, "float").toDartDouble; - var heightFalloff = _lib.getValue(this + 16, "float").toDartDouble; - var linearColor = _lib.getValue(this + 20, "*").toDartInt; - final linearColorPtr = Pointer(linearColor); - var density = _lib.getValue(this + 44, "float").toDartDouble; - var inScatteringStart = _lib.getValue(this + 48, "float").toDartDouble; - var inScatteringSize = _lib.getValue(this + 52, "float").toDartDouble; - var fogColorFromIbl = _lib.getValue(this + 56, "i8").toDartInt; - final skyColor = - self.Pointer(_lib.getValue(this + 57, "i32").toDartInt); - var enabled = _lib.getValue(this + 61, "i8").toDartInt; - return TFogOptions( - distance, - cutOffDistance, - maximumOpacity, - height, - heightFalloff, - linearColorPtr.toDart(), - density, - inScatteringStart, - inScatteringSize, - fogColorFromIbl == 1, - skyColor.cast(), - enabled == 1, - this); - } - - void setFrom(TFogOptions dartType) { - _lib.setValue(this + 0, dartType.distance.toJS, "float"); - _lib.setValue(this + 4, dartType.cutOffDistance.toJS, "float"); - _lib.setValue(this + 8, dartType.maximumOpacity.toJS, "float"); - _lib.setValue(this + 12, dartType.height.toJS, "float"); - _lib.setValue(this + 16, dartType.heightFalloff.toJS, "float"); - _lib.setValue(this + 20, dartType.linearColor.x.toJS, "double"); - _lib.setValue(this + 28, dartType.linearColor.y.toJS, "double"); - _lib.setValue(this + 36, dartType.linearColor.z.toJS, "double"); - _lib.setValue(this + 44, dartType.density.toJS, "float"); - _lib.setValue(this + 48, dartType.inScatteringStart.toJS, "float"); - _lib.setValue(this + 52, dartType.inScatteringSize.toJS, "float"); - _lib.setValue(this + 56, dartType.fogColorFromIbl ? 1.toJS : 0.toJS, "i8"); - _lib.setValue(this + 57, dartType.skyColor.addr.toJS, "*"); - _lib.setValue(this + 61, dartType.enabled ? 1.toJS : 0.toJS, "i8"); + return TFogOptions(this); } } final class TFogOptions extends self.Struct { - double _distance = 0.0; - double get distance => _distance; + double get distance { + return _lib.getValue(_address, "float").toDartDouble; + } + set distance(double val) { - _distance = val; - _lib.setValue(_address, val.toJS, "double"); + _lib.setValue(_address, val.toJS, "float"); + } + + double get cutOffDistance { + return _lib.getValue(_address + 4, "float").toDartDouble; } - double _cutOffDistance = 0.0; - double get cutOffDistance => _cutOffDistance; set cutOffDistance(double val) { - _cutOffDistance = val; - _lib.setValue(_address + 8, val.toJS, "double"); + _lib.setValue(_address + 4, val.toJS, "float"); + } + + double get maximumOpacity { + return _lib.getValue(_address + 8, "float").toDartDouble; } - double _maximumOpacity = 0.0; - double get maximumOpacity => _maximumOpacity; set maximumOpacity(double val) { - _maximumOpacity = val; - _lib.setValue(_address + 16, val.toJS, "double"); + _lib.setValue(_address + 8, val.toJS, "float"); + } + + double get height { + return _lib.getValue(_address + 12, "float").toDartDouble; } - double _height = 0.0; - double get height => _height; set height(double val) { - _height = val; - _lib.setValue(_address + 24, val.toJS, "double"); + _lib.setValue(_address + 12, val.toJS, "float"); + } + + double get heightFalloff { + return _lib.getValue(_address + 16, "float").toDartDouble; } - double _heightFalloff = 0.0; - double get heightFalloff => _heightFalloff; set heightFalloff(double val) { - _heightFalloff = val; - _lib.setValue(_address + 32, val.toJS, "double"); + _lib.setValue(_address + 16, val.toJS, "float"); } - late double3 _linearColor = double3(0.0, 0.0, 0.0, _address + 40); - double3 get linearColor => _linearColor; - set linearColor(double3 val) { - _linearColor = val; - // Assuming double3 is stored as 24 bytes (3 * 8 bytes) - _lib.setValue(_address + 40, val._address.toJS, "pointer"); + double get density { + return _lib.getValue(_address + 20, "float").toDartDouble; } - double _density = 0.0; - double get density => _density; set density(double val) { - _density = val; - _lib.setValue(_address + 64, val.toJS, "double"); + _lib.setValue(_address + 20, val.toJS, "float"); + } + + double get inScatteringStart { + return _lib.getValue(_address + 24, "float").toDartDouble; } - double _inScatteringStart = 0.0; - double get inScatteringStart => _inScatteringStart; set inScatteringStart(double val) { - _inScatteringStart = val; - _lib.setValue(_address + 72, val.toJS, "double"); + _lib.setValue(_address + 24, val.toJS, "float"); + } + + double get inScatteringSize { + return _lib.getValue(_address + 28, "float").toDartDouble; } - double _inScatteringSize = 0.0; - double get inScatteringSize => _inScatteringSize; set inScatteringSize(double val) { - _inScatteringSize = val; - _lib.setValue(_address + 80, val.toJS, "double"); + _lib.setValue(_address + 28, val.toJS, "float"); } - bool _fogColorFromIbl = false; - bool get fogColorFromIbl => _fogColorFromIbl; - set fogColorFromIbl(bool val) { - _fogColorFromIbl = val; - _lib.setValue(_address + 88, (val ? 1 : 0).toJS, "i8"); + self.Pointer get skyColor { + return self.Pointer(_lib.getValue(_address + 32, "*").toDartInt); } - self.Pointer _skyColor = self.Pointer(0); - self.Pointer get skyColor => _skyColor; set skyColor(self.Pointer val) { - _skyColor = val; - _lib.setValue(_address + 96, val.toJS, "*"); + _lib.setValue(_address + 32, val.toJS, "*"); + } + + double get linearColorR { + return _lib.getValue(_address + 36, "float").toDartDouble; + } + + set linearColorR(double val) { + _lib.setValue(_address + 36, val.toJS, "float"); + } + + double get linearColorG { + return _lib.getValue(_address + 40, "float").toDartDouble; + } + + set linearColorG(double val) { + _lib.setValue(_address + 40, val.toJS, "float"); + } + + double get linearColorB { + return _lib.getValue(_address + 44, "float").toDartDouble; + } + + set linearColorB(double val) { + _lib.setValue(_address + 44, val.toJS, "float"); + } + + bool get fogColorFromIbl { + return _lib.getValue(_address + 48, "i8").toDartInt != 0; + } + + set fogColorFromIbl(bool val) { + _lib.setValue(_address + 48, (val ? 1 : 0).toJS, "i8"); + } + + bool get enabled { + return _lib.getValue(_address + 49, "i8").toDartInt != 0; } - bool _enabled = false; - bool get enabled => _enabled; set enabled(bool val) { - _enabled = val; - _lib.setValue(_address + 104, (val ? 1 : 0).toJS, "i8"); + _lib.setValue(_address + 49, (val ? 1 : 0).toJS, "i8"); } - TFogOptions( - this._distance, - this._cutOffDistance, - this._maximumOpacity, - this._height, - this._heightFalloff, - this._linearColor, - this._density, - this._inScatteringStart, - this._inScatteringSize, - this._fogColorFromIbl, - this._skyColor, - this._enabled, - super._address); + TFogOptions(super._address); + + static Pointer malloc() { + return Pointer(_lib._malloc(50)); + } static Pointer stackAlloc() { - return Pointer( - _lib._stackAlloc(112)); // Updated size + return Pointer(_lib._stackAlloc(50)); } } @@ -7008,46 +6972,49 @@ final class double4x4 extends self.Struct { extension double3Ext on Pointer { double3 toDart() { - var x = _lib.getValue(this + 0, "double").toDartDouble; - var y = _lib.getValue(this + 8, "double").toDartDouble; - var z = _lib.getValue(this + 16, "double").toDartDouble; - return double3(x, y, z, this); - } - - void setFrom(double3 dartType) { - _lib.setValue(this + 0, dartType.x.toJS, "double"); - _lib.setValue(this + 8, dartType.y.toJS, "double"); - _lib.setValue(this + 16, dartType.z.toJS, "double"); + return double3(this); } } final class double3 extends self.Struct { - double _x = 0.0; - double get x => _x; + double get x { + return _lib.getValue(_address, "double").toDartDouble; + } + set x(double val) { - _x = val; - _lib.setValue(_address, x.toJS, "double"); + _lib.setValue(_address, val.toJS, "double"); + } + + double get y { + return _lib.getValue(_address + 8, "double").toDartDouble; } - double _y = 0.0; - double get y => _y; set y(double val) { - _y = val; - _lib.setValue(_address + 8, x.toJS, "double"); + _lib.setValue(_address + 8, val.toJS, "double"); + } + + double get z { + return _lib.getValue(_address + 16, "double").toDartDouble; } - double _z = 0.0; - double get z => _z; set z(double val) { - _z = val; - _lib.setValue(_address + 16, x.toJS, "double"); + _lib.setValue(_address + 16, val.toJS, "double"); } - double3(this._x, this._y, this._z, super._address); + double3(super._address); static Pointer stackAlloc() { return Pointer(_lib._stackAlloc(24)); } + + static Pointer create(double x, double y, double z) { + final ptr = stackAlloc(); + final instance = ptr.toDart(); + instance.x = x; + instance.y = y; + instance.z = z; + return ptr; + } } sealed class TProjection {