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