mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 20:19:49 +02:00
fix: negative hard joint handling
This commit is contained in:
1 parent
6dfb727fa2
commit
062e6e9626
5 files changed
+20
-18
No files matched your search
@@ -20,8 +20,6 @@ export async function buildTankArmors() {
|
|||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
nations.map(async (nation) => {
|
nations.map(async (nation) => {
|
||||||
if (nation !== 'france') return;
|
|
||||||
|
|
||||||
const tanks = await readXMLDVPL<{ root: VehicleDefinitionList }>(
|
const tanks = await readXMLDVPL<{ root: VehicleDefinitionList }>(
|
||||||
`${DATA}/${DOI.vehicleDefinitions}/${nation}/list.xml.dvpl`,
|
`${DATA}/${DOI.vehicleDefinitions}/${nation}/list.xml.dvpl`,
|
||||||
);
|
);
|
||||||
@@ -33,6 +31,7 @@ export async function buildTankArmors() {
|
|||||||
// if (id !== 7297) continue; // 60tp
|
// if (id !== 7297) continue; // 60tp
|
||||||
// if (id !== 5137) continue; // tiger ii
|
// if (id !== 5137) continue; // tiger ii
|
||||||
// if (id !== 24609) continue; // concept 1b
|
// if (id !== 24609) continue; // concept 1b
|
||||||
|
if (id !== 5681) continue; // 121b
|
||||||
|
|
||||||
console.log(`Building armor ${id} @ ${nation}/${tankKey}`);
|
console.log(`Building armor ${id} @ ${nation}/${tankKey}`);
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
ModelDefinitions,
|
ModelDefinitions,
|
||||||
modelDefinitions,
|
modelDefinitions,
|
||||||
} from '../../../../../../../core/blitzkrieg/modelDefinitions';
|
} from '../../../../../../../core/blitzkrieg/modelDefinitions';
|
||||||
|
import { nameToArmorId } from '../../../../../../../core/blitzkrieg/nameToArmorId';
|
||||||
import { useTankopedia } from '../../../../../../../stores/tankopedia';
|
import { useTankopedia } from '../../../../../../../stores/tankopedia';
|
||||||
import { Lighting } from '../../Lighting';
|
import { Lighting } from '../../Lighting';
|
||||||
|
|
||||||
@@ -108,7 +109,7 @@ export function TankArmor({ ...props }: TankArmorProps) {
|
|||||||
>
|
>
|
||||||
{armorNodes.map((node) => {
|
{armorNodes.map((node) => {
|
||||||
const isHull = node.name.startsWith('hull_');
|
const isHull = node.name.startsWith('hull_');
|
||||||
const armorId = parseInt(node.name.match(/.+_armor_(\d+)/)![1]);
|
const armorId = nameToArmorId(node.name);
|
||||||
const isVisible = isHull;
|
const isVisible = isHull;
|
||||||
const thickness = tankModelDefinition.armor.thickness[armorId];
|
const thickness = tankModelDefinition.armor.thickness[armorId];
|
||||||
const isSpaced = tankModelDefinition.armor.spaced?.includes(armorId);
|
const isSpaced = tankModelDefinition.armor.spaced?.includes(armorId);
|
||||||
@@ -170,7 +171,7 @@ export function TankArmor({ ...props }: TankArmorProps) {
|
|||||||
.padStart(2, '0')}`,
|
.padStart(2, '0')}`,
|
||||||
);
|
);
|
||||||
const isVisible = isCurrentTurret;
|
const isVisible = isCurrentTurret;
|
||||||
const armorId = parseInt(node.name.match(/.+_armor_(\d+)/)![1]);
|
const armorId = nameToArmorId(node.name);
|
||||||
const thickness = turretModelDefinition.armor.thickness[armorId];
|
const thickness = turretModelDefinition.armor.thickness[armorId];
|
||||||
const isSpaced =
|
const isSpaced =
|
||||||
turretModelDefinition.armor.spaced?.includes(armorId);
|
turretModelDefinition.armor.spaced?.includes(armorId);
|
||||||
@@ -214,7 +215,7 @@ export function TankArmor({ ...props }: TankArmorProps) {
|
|||||||
`gun_${gunModelDefinition.model.toString().padStart(2, '0')}`,
|
`gun_${gunModelDefinition.model.toString().padStart(2, '0')}`,
|
||||||
);
|
);
|
||||||
const isVisible = isCurrentGun;
|
const isVisible = isCurrentGun;
|
||||||
const armorId = parseInt(node.name.match(/.+_armor_(\d+)/)![1]);
|
const armorId = nameToArmorId(node.name);
|
||||||
const thickness = gunModelDefinition.armor.thickness[armorId];
|
const thickness = gunModelDefinition.armor.thickness[armorId];
|
||||||
const isSpaced =
|
const isSpaced =
|
||||||
gunModelDefinition.armor.spaced?.includes(armorId);
|
gunModelDefinition.armor.spaced?.includes(armorId);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export default function Page({ params }: { params: { id: string } }) {
|
|||||||
draft.model.hullYaw = 0;
|
draft.model.hullYaw = 0;
|
||||||
draft.model.turretYaw = 0;
|
draft.model.turretYaw = 0;
|
||||||
draft.model.gunPitch = 0;
|
draft.model.gunPitch = 0;
|
||||||
draft.mode = 'armor';
|
draft.mode = 'model';
|
||||||
draft.areTanksAssigned = true;
|
draft.areTanksAssigned = true;
|
||||||
|
|
||||||
if (!draft.areTanksAssigned) return;
|
if (!draft.areTanksAssigned) return;
|
||||||
|
|||||||
@@ -58,7 +58,10 @@ export async function extractArmor(data: string, fileName: string) {
|
|||||||
|
|
||||||
attributes.get(attribute)!.push(value);
|
attributes.get(attribute)!.push(value);
|
||||||
|
|
||||||
if (attribute === VertexAttribute.HARD_JOINTINDEX) {
|
if (
|
||||||
|
attribute === VertexAttribute.HARD_JOINTINDEX &&
|
||||||
|
value[0] !== -1
|
||||||
|
) {
|
||||||
hardJointIndices.add(value[0]);
|
hardJointIndices.add(value[0]);
|
||||||
vertexHardJointIndices.set(index, value[0]);
|
vertexHardJointIndices.set(index, value[0]);
|
||||||
}
|
}
|
||||||
@@ -99,17 +102,10 @@ export async function extractArmor(data: string, fileName: string) {
|
|||||||
.setType('SCALAR')
|
.setType('SCALAR')
|
||||||
.setArray(
|
.setArray(
|
||||||
new Uint16Array(
|
new Uint16Array(
|
||||||
polygonGroup.indices.filter((index) => {
|
polygonGroup.indices.filter(
|
||||||
if (!vertexHardJointIndices.has(index)) {
|
(index) =>
|
||||||
throw new Error(
|
vertexHardJointIndices.get(index) === hardJointIndex,
|
||||||
`Missing vertex hard joint index for index ${index}`,
|
),
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
vertexHardJointIndices.get(index)! === hardJointIndex
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.setBuffer(buffer);
|
.setBuffer(buffer);
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
export function nameToArmorId(name: string) {
|
||||||
|
const match = name.match(/.+_armor_(\d+)/);
|
||||||
|
const group1 = match![1];
|
||||||
|
|
||||||
|
return parseInt(group1);
|
||||||
|
}
|
||||||
Reference in new issue
Block a user