remove TMaterialKey struct and pass directly as function params

This commit is contained in:
Nick Fisher
2025-05-14 08:15:09 +08:00
parent d392daa2e6
commit 11ff6c9053
10 changed files with 1196 additions and 754 deletions

View File

@@ -887,11 +887,86 @@ external void Gizmo_unhighlight(
);
@ffi.Native<
ffi.Pointer<TMaterialInstance> Function(ffi.Pointer<TMaterialProvider>,
ffi.Pointer<TMaterialKey>)>(isLeaf: true)
ffi.Pointer<TMaterialInstance> Function(
ffi.Pointer<TMaterialProvider>,
ffi.Bool,
ffi.Bool,
ffi.Bool,
ffi.Bool,
ffi.Bool,
ffi.Bool,
ffi.Bool,
ffi.Bool,
ffi.Int,
ffi.Bool,
ffi.Bool,
ffi.Uint8,
ffi.Bool,
ffi.Uint8,
ffi.Uint8,
ffi.Bool,
ffi.Uint8,
ffi.Bool,
ffi.Uint8,
ffi.Bool,
ffi.Uint8,
ffi.Bool,
ffi.Bool,
ffi.Bool,
ffi.Uint8,
ffi.Uint8,
ffi.Uint8,
ffi.Bool,
ffi.Uint8,
ffi.Bool,
ffi.Uint8,
ffi.Bool,
ffi.Uint8,
ffi.Bool,
ffi.Uint8,
ffi.Bool,
ffi.Bool,
ffi.Bool)>(isLeaf: true)
external ffi.Pointer<TMaterialInstance> MaterialProvider_createMaterialInstance(
ffi.Pointer<TMaterialProvider> provider,
ffi.Pointer<TMaterialKey> key,
bool doubleSided,
bool unlit,
bool hasVertexColors,
bool hasBaseColorTexture,
bool hasNormalTexture,
bool hasOcclusionTexture,
bool hasEmissiveTexture,
bool useSpecularGlossiness,
int alphaMode,
bool enableDiagnostics,
bool hasMetallicRoughnessTexture,
int metallicRoughnessUV,
bool hasSpecularGlossinessTexture,
int specularGlossinessUV,
int baseColorUV,
bool hasClearCoatTexture,
int clearCoatUV,
bool hasClearCoatRoughnessTexture,
int clearCoatRoughnessUV,
bool hasClearCoatNormalTexture,
int clearCoatNormalUV,
bool hasClearCoat,
bool hasTransmission,
bool hasTextureTransforms,
int emissiveUV,
int aoUV,
int normalUV,
bool hasTransmissionTexture,
int transmissionUV,
bool hasSheenColorTexture,
int sheenColorUV,
bool hasSheenRoughnessTexture,
int sheenRoughnessUV,
bool hasVolumeThicknessTexture,
int volumeThicknessUV,
bool hasSheen,
bool hasIOR,
bool hasVolume,
);
@ffi.Native<
@@ -2121,14 +2196,88 @@ external void SceneAsset_createGeometryRenderThread(
@ffi.Native<
ffi.Void Function(
ffi.Pointer<TMaterialProvider>,
ffi.Pointer<TMaterialKey>,
ffi.Bool,
ffi.Bool,
ffi.Bool,
ffi.Bool,
ffi.Bool,
ffi.Bool,
ffi.Bool,
ffi.Bool,
ffi.Int,
ffi.Bool,
ffi.Bool,
ffi.Uint8,
ffi.Bool,
ffi.Uint8,
ffi.Uint8,
ffi.Bool,
ffi.Uint8,
ffi.Bool,
ffi.Uint8,
ffi.Bool,
ffi.Uint8,
ffi.Bool,
ffi.Bool,
ffi.Bool,
ffi.Uint8,
ffi.Uint8,
ffi.Uint8,
ffi.Bool,
ffi.Uint8,
ffi.Bool,
ffi.Uint8,
ffi.Bool,
ffi.Uint8,
ffi.Bool,
ffi.Uint8,
ffi.Bool,
ffi.Bool,
ffi.Bool,
ffi.Pointer<
ffi.NativeFunction<
ffi.Void Function(
ffi.Pointer<TMaterialInstance>)>>)>(isLeaf: true)
external void MaterialProvider_createMaterialInstanceRenderThread(
ffi.Pointer<TMaterialProvider> tMaterialProvider,
ffi.Pointer<TMaterialKey> tKey,
bool doubleSided,
bool unlit,
bool hasVertexColors,
bool hasBaseColorTexture,
bool hasNormalTexture,
bool hasOcclusionTexture,
bool hasEmissiveTexture,
bool useSpecularGlossiness,
int alphaMode,
bool enableDiagnostics,
bool hasMetallicRoughnessTexture,
int metallicRoughnessUV,
bool hasSpecularGlossinessTexture,
int specularGlossinessUV,
int baseColorUV,
bool hasClearCoatTexture,
int clearCoatUV,
bool hasClearCoatRoughnessTexture,
int clearCoatRoughnessUV,
bool hasClearCoatNormalTexture,
int clearCoatNormalUV,
bool hasClearCoat,
bool hasTransmission,
bool hasTextureTransforms,
int emissiveUV,
int aoUV,
int normalUV,
bool hasTransmissionTexture,
int transmissionUV,
bool hasSheenColorTexture,
int sheenColorUV,
bool hasSheenRoughnessTexture,
int sheenRoughnessUV,
bool hasVolumeThicknessTexture,
int volumeThicknessUV,
bool hasSheen,
bool hasIOR,
bool hasVolume,
ffi.Pointer<
ffi.NativeFunction<ffi.Void Function(ffi.Pointer<TMaterialInstance>)>>
callback,
@@ -3323,134 +3472,6 @@ final class TFilamentAsset extends ffi.Opaque {}
final class TColorGrading extends ffi.Opaque {}
final class UnnamedStruct1 extends ffi.Struct {
@ffi.Bool()
external bool hasMetallicRoughnessTexture;
@ffi.Uint8()
external int metallicRoughnessUV;
}
final class UnnamedStruct2 extends ffi.Struct {
@ffi.Bool()
external bool hasSpecularGlossinessTexture;
@ffi.Uint8()
external int specularGlossinessUV;
}
final class UnnamedUnion1 extends ffi.Union {
external UnnamedStruct1 unnamed;
external UnnamedStruct2 unnamed$1;
}
final class TMaterialKey extends ffi.Struct {
@ffi.Bool()
external bool doubleSided;
@ffi.Bool()
external bool unlit;
@ffi.Bool()
external bool hasVertexColors;
@ffi.Bool()
external bool hasBaseColorTexture;
@ffi.Bool()
external bool hasNormalTexture;
@ffi.Bool()
external bool hasOcclusionTexture;
@ffi.Bool()
external bool hasEmissiveTexture;
@ffi.Bool()
external bool useSpecularGlossiness;
@ffi.Int()
external int alphaMode;
@ffi.Bool()
external bool enableDiagnostics;
external UnnamedUnion1 unnamed;
@ffi.Uint8()
external int baseColorUV;
@ffi.Bool()
external bool hasClearCoatTexture;
@ffi.Uint8()
external int clearCoatUV;
@ffi.Bool()
external bool hasClearCoatRoughnessTexture;
@ffi.Uint8()
external int clearCoatRoughnessUV;
@ffi.Bool()
external bool hasClearCoatNormalTexture;
@ffi.Uint8()
external int clearCoatNormalUV;
@ffi.Bool()
external bool hasClearCoat;
@ffi.Bool()
external bool hasTransmission;
@ffi.Bool()
external bool hasTextureTransforms;
@ffi.Uint8()
external int emissiveUV;
@ffi.Uint8()
external int aoUV;
@ffi.Uint8()
external int normalUV;
@ffi.Bool()
external bool hasTransmissionTexture;
@ffi.Uint8()
external int transmissionUV;
@ffi.Bool()
external bool hasSheenColorTexture;
@ffi.Uint8()
external int sheenColorUV;
@ffi.Bool()
external bool hasSheenRoughnessTexture;
@ffi.Uint8()
external int sheenRoughnessUV;
@ffi.Bool()
external bool hasVolumeThicknessTexture;
@ffi.Uint8()
external int volumeThicknessUV;
@ffi.Bool()
external bool hasSheen;
@ffi.Bool()
external bool hasIOR;
@ffi.Bool()
external bool hasVolume;
}
final class double3 extends ffi.Struct {
@ffi.Double()
external double x;

View File

@@ -255,7 +255,7 @@ sealed class Struct extends NativeType {
Struct(this._address);
static create<T extends Struct>() {
switch (T) {
switch (T) {
case double4x4:
final ptr = double4x4.stackAlloc();
final arr1 =
@@ -901,7 +901,44 @@ extension type NativeLibrary(JSObject _) implements JSObject {
);
external Pointer<TMaterialInstance> _MaterialProvider_createMaterialInstance(
Pointer<TMaterialProvider> provider,
Pointer<TMaterialKey> key,
bool doubleSided,
bool unlit,
bool hasVertexColors,
bool hasBaseColorTexture,
bool hasNormalTexture,
bool hasOcclusionTexture,
bool hasEmissiveTexture,
bool useSpecularGlossiness,
int alphaMode,
bool enableDiagnostics,
bool hasMetallicRoughnessTexture,
int metallicRoughnessUV,
bool hasSpecularGlossinessTexture,
int specularGlossinessUV,
int baseColorUV,
bool hasClearCoatTexture,
int clearCoatUV,
bool hasClearCoatRoughnessTexture,
int clearCoatRoughnessUV,
bool hasClearCoatNormalTexture,
int clearCoatNormalUV,
bool hasClearCoat,
bool hasTransmission,
bool hasTextureTransforms,
int emissiveUV,
int aoUV,
int normalUV,
bool hasTransmissionTexture,
int transmissionUV,
bool hasSheenColorTexture,
int sheenColorUV,
bool hasSheenRoughnessTexture,
int sheenRoughnessUV,
bool hasVolumeThicknessTexture,
int volumeThicknessUV,
bool hasSheen,
bool hasIOR,
bool hasVolume,
);
external Pointer<TRenderTarget> _RenderTarget_create(
Pointer<TEngine> tEngine,
@@ -1558,7 +1595,44 @@ extension type NativeLibrary(JSObject _) implements JSObject {
);
external void _MaterialProvider_createMaterialInstanceRenderThread(
Pointer<TMaterialProvider> tMaterialProvider,
Pointer<TMaterialKey> tKey,
bool doubleSided,
bool unlit,
bool hasVertexColors,
bool hasBaseColorTexture,
bool hasNormalTexture,
bool hasOcclusionTexture,
bool hasEmissiveTexture,
bool useSpecularGlossiness,
int alphaMode,
bool enableDiagnostics,
bool hasMetallicRoughnessTexture,
int metallicRoughnessUV,
bool hasSpecularGlossinessTexture,
int specularGlossinessUV,
int baseColorUV,
bool hasClearCoatTexture,
int clearCoatUV,
bool hasClearCoatRoughnessTexture,
int clearCoatRoughnessUV,
bool hasClearCoatNormalTexture,
int clearCoatNormalUV,
bool hasClearCoat,
bool hasTransmission,
bool hasTextureTransforms,
int emissiveUV,
int aoUV,
int normalUV,
bool hasTransmissionTexture,
int transmissionUV,
bool hasSheenColorTexture,
int sheenColorUV,
bool hasSheenRoughnessTexture,
int sheenRoughnessUV,
bool hasVolumeThicknessTexture,
int volumeThicknessUV,
bool hasSheen,
bool hasIOR,
bool hasVolume,
Pointer<self.NativeFunction<void Function(PointerClass<TMaterialInstance>)>>
callback,
);
@@ -3143,10 +3217,85 @@ void Gizmo_unhighlight(
self.Pointer<TMaterialInstance> MaterialProvider_createMaterialInstance(
self.Pointer<TMaterialProvider> provider,
self.Pointer<TMaterialKey> key,
bool doubleSided,
bool unlit,
bool hasVertexColors,
bool hasBaseColorTexture,
bool hasNormalTexture,
bool hasOcclusionTexture,
bool hasEmissiveTexture,
bool useSpecularGlossiness,
int alphaMode,
bool enableDiagnostics,
bool hasMetallicRoughnessTexture,
int metallicRoughnessUV,
bool hasSpecularGlossinessTexture,
int specularGlossinessUV,
int baseColorUV,
bool hasClearCoatTexture,
int clearCoatUV,
bool hasClearCoatRoughnessTexture,
int clearCoatRoughnessUV,
bool hasClearCoatNormalTexture,
int clearCoatNormalUV,
bool hasClearCoat,
bool hasTransmission,
bool hasTextureTransforms,
int emissiveUV,
int aoUV,
int normalUV,
bool hasTransmissionTexture,
int transmissionUV,
bool hasSheenColorTexture,
int sheenColorUV,
bool hasSheenRoughnessTexture,
int sheenRoughnessUV,
bool hasVolumeThicknessTexture,
int volumeThicknessUV,
bool hasSheen,
bool hasIOR,
bool hasVolume,
) {
final result = _lib._MaterialProvider_createMaterialInstance(
provider.cast(), key.cast());
provider.cast(),
doubleSided,
unlit,
hasVertexColors,
hasBaseColorTexture,
hasNormalTexture,
hasOcclusionTexture,
hasEmissiveTexture,
useSpecularGlossiness,
alphaMode,
enableDiagnostics,
hasMetallicRoughnessTexture,
metallicRoughnessUV,
hasSpecularGlossinessTexture,
specularGlossinessUV,
baseColorUV,
hasClearCoatTexture,
clearCoatUV,
hasClearCoatRoughnessTexture,
clearCoatRoughnessUV,
hasClearCoatNormalTexture,
clearCoatNormalUV,
hasClearCoat,
hasTransmission,
hasTextureTransforms,
emissiveUV,
aoUV,
normalUV,
hasTransmissionTexture,
transmissionUV,
hasSheenColorTexture,
sheenColorUV,
hasSheenRoughnessTexture,
sheenRoughnessUV,
hasVolumeThicknessTexture,
volumeThicknessUV,
hasSheen,
hasIOR,
hasVolume);
return self.Pointer<TMaterialInstance>(result);
}
@@ -4493,12 +4642,88 @@ void SceneAsset_createGeometryRenderThread(
void MaterialProvider_createMaterialInstanceRenderThread(
self.Pointer<TMaterialProvider> tMaterialProvider,
self.Pointer<TMaterialKey> tKey,
bool doubleSided,
bool unlit,
bool hasVertexColors,
bool hasBaseColorTexture,
bool hasNormalTexture,
bool hasOcclusionTexture,
bool hasEmissiveTexture,
bool useSpecularGlossiness,
int alphaMode,
bool enableDiagnostics,
bool hasMetallicRoughnessTexture,
int metallicRoughnessUV,
bool hasSpecularGlossinessTexture,
int specularGlossinessUV,
int baseColorUV,
bool hasClearCoatTexture,
int clearCoatUV,
bool hasClearCoatRoughnessTexture,
int clearCoatRoughnessUV,
bool hasClearCoatNormalTexture,
int clearCoatNormalUV,
bool hasClearCoat,
bool hasTransmission,
bool hasTextureTransforms,
int emissiveUV,
int aoUV,
int normalUV,
bool hasTransmissionTexture,
int transmissionUV,
bool hasSheenColorTexture,
int sheenColorUV,
bool hasSheenRoughnessTexture,
int sheenRoughnessUV,
bool hasVolumeThicknessTexture,
int volumeThicknessUV,
bool hasSheen,
bool hasIOR,
bool hasVolume,
self.Pointer<self.NativeFunction<void Function(Pointer<TMaterialInstance>)>>
callback,
) {
final result = _lib._MaterialProvider_createMaterialInstanceRenderThread(
tMaterialProvider.cast(), tKey.cast(), callback.cast());
tMaterialProvider.cast(),
doubleSided,
unlit,
hasVertexColors,
hasBaseColorTexture,
hasNormalTexture,
hasOcclusionTexture,
hasEmissiveTexture,
useSpecularGlossiness,
alphaMode,
enableDiagnostics,
hasMetallicRoughnessTexture,
metallicRoughnessUV,
hasSpecularGlossinessTexture,
specularGlossinessUV,
baseColorUV,
hasClearCoatTexture,
clearCoatUV,
hasClearCoatRoughnessTexture,
clearCoatRoughnessUV,
hasClearCoatNormalTexture,
clearCoatNormalUV,
hasClearCoat,
hasTransmission,
hasTextureTransforms,
emissiveUV,
aoUV,
normalUV,
hasTransmissionTexture,
transmissionUV,
hasSheenColorTexture,
sheenColorUV,
hasSheenRoughnessTexture,
sheenRoughnessUV,
hasVolumeThicknessTexture,
volumeThicknessUV,
hasSheen,
hasIOR,
hasVolume,
callback.cast());
return result;
}
@@ -6415,22 +6640,6 @@ sealed class TGizmoAxis {
static const Z = 2;
}
extension TMaterialKeyExt on Pointer<TMaterialKey> {
TMaterialKey toDart() {
return TMaterialKey(this);
}
void setFrom(TMaterialKey dartType) {}
}
final class TMaterialKey extends self.Struct {
TMaterialKey(super._address);
static Pointer<TMaterialKey> stackAlloc() {
return Pointer<TMaterialKey>(_lib._stackAlloc<TMaterialKey>(0));
}
}
extension TSkyboxExt on Pointer<TSkybox> {
TSkybox toDart() {
return TSkybox(this);