mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
fix: streak lod
This commit is contained in:
1 parent
c10060decc
commit
35d03c9e21
3 files changed
+24
-7
No files matched your search
Binary file not shown.
@@ -593,9 +593,9 @@ if (allTargets || targets?.includes('tankModels')) {
|
|||||||
|
|
||||||
// if (id !== 15697) continue; // chieftain TODO: investigate vertices stream over read
|
// if (id !== 15697) continue; // chieftain TODO: investigate vertices stream over read
|
||||||
// if (id !== 24609) continue; // concept 1b
|
// if (id !== 24609) continue; // concept 1b
|
||||||
if (id !== 16401) continue; // waffle
|
// if (id !== 16401) continue; // waffle
|
||||||
// if (id !== 7425) continue; // isu 152
|
// if (id !== 7425) continue; // isu 152
|
||||||
// if (id !== 10369) continue; // mino
|
if (id !== 10369) continue; // mino
|
||||||
// if (id !== 4417) continue; // amx m4 mle
|
// if (id !== 4417) continue; // amx m4 mle
|
||||||
// if (id !== 7297) continue; // 60tp
|
// if (id !== 7297) continue; // 60tp
|
||||||
// if (id !== 1) continue; // t-34
|
// if (id !== 1) continue; // t-34
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Document, Material, Node, Scene } from '@gltf-transform/core';
|
import { Document, Material, Node, Scene } from '@gltf-transform/core';
|
||||||
|
import { writeFile } from 'fs/promises';
|
||||||
import { range, times } from 'lodash';
|
import { range, times } from 'lodash';
|
||||||
import { dirname } from 'path';
|
import { dirname } from 'path';
|
||||||
import {
|
import {
|
||||||
@@ -14,9 +15,9 @@ import { ScgStream, vertexAttributeVectorSizes } from '../streams/scg';
|
|||||||
import { VertexAttribute } from '../streams/scpg';
|
import { VertexAttribute } from '../streams/scpg';
|
||||||
import { readDVPLFile } from './readDVPLFile';
|
import { readDVPLFile } from './readDVPLFile';
|
||||||
|
|
||||||
// BigInt.prototype.toJSON = function () {
|
BigInt.prototype.toJSON = function () {
|
||||||
// return this.toString();
|
return this.toString();
|
||||||
// };
|
};
|
||||||
|
|
||||||
const MAX_FLOAT32 = 2 ** 127 * (2 - 2 ** -23);
|
const MAX_FLOAT32 = 2 ** 127 * (2 - 2 ** -23);
|
||||||
|
|
||||||
@@ -58,6 +59,8 @@ export async function extractModel(
|
|||||||
const buffer = document.createBuffer();
|
const buffer = document.createBuffer();
|
||||||
const materials = new Map<bigint, Material | bigint>();
|
const materials = new Map<bigint, Material | bigint>();
|
||||||
|
|
||||||
|
writeFile('test.sc2.json', JSON.stringify(sc2, null, 2));
|
||||||
|
|
||||||
// create materials
|
// create materials
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
sc2['#dataNodes'].map(async (node) => {
|
sc2['#dataNodes'].map(async (node) => {
|
||||||
@@ -208,7 +211,7 @@ export async function extractModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
case 'RenderComponent': {
|
case 'RenderComponent': {
|
||||||
let minLODDistanceBatchId: undefined | number = undefined;
|
let minLODDistanceBatchId: undefined | number;
|
||||||
|
|
||||||
if (component['rc.renderObj']['rb0.lodIndex'] === -1) {
|
if (component['rc.renderObj']['rb0.lodIndex'] === -1) {
|
||||||
minLODDistanceBatchId = 0;
|
minLODDistanceBatchId = 0;
|
||||||
@@ -226,6 +229,8 @@ export async function extractModel(
|
|||||||
|
|
||||||
let minLODDistance = Infinity;
|
let minLODDistance = Infinity;
|
||||||
let isFirstMaxFloat = true;
|
let isFirstMaxFloat = true;
|
||||||
|
let lodIndexStreak = 0;
|
||||||
|
let lodIndexStreakIndex: undefined | number = undefined;
|
||||||
|
|
||||||
range(component['rc.renderObj']['ro.batchCount']).forEach(
|
range(component['rc.renderObj']['ro.batchCount']).forEach(
|
||||||
(id) => {
|
(id) => {
|
||||||
@@ -234,8 +239,16 @@ export async function extractModel(
|
|||||||
const lodDistance =
|
const lodDistance =
|
||||||
lodList['lc.loddist'][`distance${lodIndex}`];
|
lodList['lc.loddist'][`distance${lodIndex}`];
|
||||||
|
|
||||||
|
if (lodIndexStreakIndex === lodIndex) {
|
||||||
|
lodIndexStreak++;
|
||||||
|
} else {
|
||||||
|
lodIndexStreak = 0;
|
||||||
|
lodIndexStreakIndex = lodIndex;
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
lodDistance <= minLODDistance ||
|
lodDistance < minLODDistance ||
|
||||||
|
(lodDistance === minLODDistance && lodIndexStreak > 0) ||
|
||||||
(lodDistance === MAX_FLOAT32 && isFirstMaxFloat)
|
(lodDistance === MAX_FLOAT32 && isFirstMaxFloat)
|
||||||
) {
|
) {
|
||||||
if (lodDistance === MAX_FLOAT32) isFirstMaxFloat = false;
|
if (lodDistance === MAX_FLOAT32) isFirstMaxFloat = false;
|
||||||
@@ -246,6 +259,10 @@ export async function extractModel(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hierarchy.name === 'chassis_track_L') {
|
||||||
|
console.log(minLODDistanceBatchId);
|
||||||
|
}
|
||||||
|
|
||||||
const batch =
|
const batch =
|
||||||
component['rc.renderObj']['ro.batches'][
|
component['rc.renderObj']['ro.batches'][
|
||||||
minLODDistanceBatchId!.toString().padStart(4, '0')
|
minLODDistanceBatchId!.toString().padStart(4, '0')
|
||||||
|
|||||||
Reference in new issue
Block a user