Skip to content

Commit

Permalink
feat: fixed textures + improved loadings
Browse files Browse the repository at this point in the history
  • Loading branch information
jvenin committed Apr 23, 2024
1 parent 1a797e1 commit 3308aad
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 21 deletions.
16 changes: 8 additions & 8 deletions lib/classes/gsf/header2/material_attribute.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ class MaterialAttribute {
if (other is MaterialAttribute) {
return useHardAlpha == other.useHardAlpha &&
useSoftAlpha == other.useSoftAlpha &&
useNm == other.useNm &&
useShininessShader == other.useShininessShader &&
usePlayerColor == other.usePlayerColor &&
useWaterShader == other.useWaterShader;
//useNm == other.useNm &&
//useShininessShader == other.useShininessShader &&
usePlayerColor == other.usePlayerColor;
//useWaterShader == other.useWaterShader;
}
return false;
}
Expand All @@ -48,9 +48,9 @@ class MaterialAttribute {
int get hashCode {
return useHardAlpha.hashCode ^
useSoftAlpha.hashCode ^
useNm.hashCode ^
useShininessShader.hashCode ^
usePlayerColor.hashCode ^
useWaterShader.hashCode;
//useNm.hashCode ^
//useShininessShader.hashCode ^
usePlayerColor.hashCode;
//useWaterShader.hashCode;
}
}
27 changes: 17 additions & 10 deletions lib/classes/model.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dart:isolate';
import 'dart:typed_data';
import 'dart:ui' as ui;

Expand Down Expand Up @@ -79,19 +80,25 @@ class Model {
numChannels: 4,
);

for (final p in fullTexture) {
for (var data in _texturesOffsets.entries) {
final textureImage = data.key.imageData;
final textureOffset = data.value.$1;
if (textureImage!.height > p.y &&
(p.x - textureOffset) > 0 &&
textureImage.width > (p.x - textureOffset)) {
final pixel = textureImage.getPixel(p.x - textureOffset, p.y);
p.setRgba(pixel.r, pixel.g, pixel.b, pixel.a);
img.Image createFullTexture(
img.Image image, Map<ModelTexture, (int, img.Image)> offsets) {
for (final p in image) {
for (var data in offsets.entries) {
final textureImage = data.key.imageData;
final textureOffset = data.value.$1;
if (textureImage!.height > p.y &&
(p.x - textureOffset) > 0 &&
textureImage.width > (p.x - textureOffset)) {
final pixel = textureImage.getPixel(p.x - textureOffset, p.y);
p.setRgba(pixel.r, pixel.g, pixel.b, pixel.a);
}
}
}
return image;
}

// to avoid blocking UI this is executed in separate isolate
fullTexture = await Isolate.run(
() => createFullTexture(fullTexture, _texturesOffsets));
_composedModelImage =
await (ModelTexture(attribute: MaterialAttribute.zero(), path: "")
..imageData = fullTexture)
Expand Down
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,8 @@ packages:
dependency: "direct main"
description:
path: "."
ref: "9fb1ca17"
resolved-ref: "9fb1ca1757d98acc125d1809a2787b19f2a617a5"
ref: efef5ae3
resolved-ref: efef5ae3357a9d851f33282ff4a63dae6b096534
url: "http://github.com/arceusVen1/image-with-dds"
source: git
version: "4.1.8"
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ dependencies:
image:
git:
url: http://github.com/arceusVen1/image-with-dds
ref: 9fb1ca17
ref: efef5ae3
dev_dependencies:
flutter_test:
sdk: flutter
Expand Down

0 comments on commit 3308aad

Please sign in to comment.