pass TFogOptions by value, not pointer, and rearrange struct fields to minimize alignment issues

This commit is contained in:
Nick Fisher
2025-06-05 16:41:08 +08:00
parent acf03ea0c7
commit 9ae7c784df

View File

@@ -224,21 +224,22 @@ class FFIView extends View {
@override @override
Future setFogOptions(FogOptions options) async { Future setFogOptions(FogOptions options) async {
final tFogOptions = Struct.create<TFogOptions>(); final tFogOptions = Struct.create<TFogOptions>();
tFogOptions.cutOffDistance = options.cutOffDistance;
tFogOptions.enabled = options.enabled;
tFogOptions.density = options.density;
tFogOptions.distance = options.distance; tFogOptions.distance = options.distance;
tFogOptions.fogColorFromIbl = options.fogColorFromIbl; tFogOptions.cutOffDistance = options.cutOffDistance;
tFogOptions.maximumOpacity = options.maximumOpacity;
tFogOptions.height = options.height; tFogOptions.height = options.height;
tFogOptions.heightFalloff = options.heightFalloff; tFogOptions.heightFalloff = options.heightFalloff;
tFogOptions.inScatteringSize = options.inScatteringSize; tFogOptions.density = options.density;
tFogOptions.inScatteringStart = options.inScatteringStart; tFogOptions.inScatteringStart = options.inScatteringStart;
tFogOptions.maximumOpacity = options.maximumOpacity; tFogOptions.inScatteringSize = options.inScatteringSize;
tFogOptions.fogColorFromIbl = options.fogColorFromIbl;
tFogOptions.skyColor = tFogOptions.skyColor =
(options.skyColor as FFITexture?)?.pointer ?? nullptr; (options.skyColor as FFITexture?)?.pointer ?? nullptr;
tFogOptions.linearColor.x = options.linearColor.r; tFogOptions.linearColorR = options.linearColor.r;
tFogOptions.linearColor.y = options.linearColor.x; tFogOptions.linearColorG = options.linearColor.g;
tFogOptions.linearColor.z = options.linearColor.x; tFogOptions.linearColorB = options.linearColor.b;
View_setFogOptions(this.view, tFogOptions.address); tFogOptions.enabled = options.enabled;
View_setFogOptions(this.view, tFogOptions);
} }
} }