fix: negative hard joint handling

This commit is contained in:
TrèsAbhi committed 2024-01-12 19:58:02 -06:00
1 parent 6dfb727fa2
commit 062e6e9626
5 files changed
+20 -18

No files matched your search

+8 -12
View File
@@ -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);
+6
View File
@@ -0,0 +1,6 @@
export function nameToArmorId(name: string) {
const match = name.match(/.+_armor_(\d+)/);
const group1 = match![1];
return parseInt(group1);
}