diff --git a/src/components/ArmorMesh/components/Armor/index.tsx b/src/components/ArmorMesh/components/Armor/index.tsx index a46b6f96e..05647e651 100644 --- a/src/components/ArmorMesh/components/Armor/index.tsx +++ b/src/components/ArmorMesh/components/Armor/index.tsx @@ -230,12 +230,13 @@ export function ArmorMesh({ shell.caliber > 2 * (event.object.userData.thickness * thicknessCoefficient); - const normalization = twoCalibersRule - ? ((shell.normalization ?? 0) * 1.4 * shell.caliber) / - (2 * - event.object.userData.thickness * - thicknessCoefficient) - : shell.normalization ?? 0; + const normalization = + twoCalibersRule && event.object.userData.thickness > 0 + ? ((shell.normalization ?? 0) * 1.4 * shell.caliber) / + (2 * + event.object.userData.thickness * + thicknessCoefficient) + : shell.normalization ?? 0; const angled = (event.object.userData.thickness * thicknessCoefficient) / Math.cos(angle - degToRad(normalization)); diff --git a/src/components/ArmorMesh/components/Armor/shaders/fragment.glsl b/src/components/ArmorMesh/components/Armor/shaders/fragment.glsl index 17754268e..b7387df3b 100644 --- a/src/components/ArmorMesh/components/Armor/shaders/fragment.glsl +++ b/src/components/ArmorMesh/components/Armor/shaders/fragment.glsl @@ -63,7 +63,7 @@ void main() { if (isUnderSpacedArmor) { // spaced armor on the other hand, does care about angle - bool spacedArmorTwoCalibersRule = caliber > 2.0 * spacedArmorNominalThickness; + bool spacedArmorTwoCalibersRule = caliber > 2.0 * spacedArmorNominalThickness && spacedArmorNominalThickness > 0.0; float finalSpacedArmorNormalization = spacedArmorTwoCalibersRule ? (normalization * 1.4 * caliber) / (2.0 * spacedArmorNominalThickness) : normalization; float finalSpacedArmorThickness = spacedArmorNominalThickness / cos(spacedArmorAngle - finalSpacedArmorNormalization); remainingPenetration -= finalSpacedArmorThickness; @@ -79,7 +79,7 @@ void main() { remainingPenetration -= 0.5 * remainingPenetration * distanceFromSpacedArmor; } - bool coreArmorTwoCalibersRule = caliber > 2.0 * thickness; + bool coreArmorTwoCalibersRule = caliber > 2.0 * thickness && thickness > 0.0; float finalNormalization = coreArmorTwoCalibersRule ? (normalization * 1.4 * caliber) / (2.0 * thickness) : normalization; float finalCoreArmorThickness = thickness / cos(coreArmorangle - finalNormalization); float deltaPenetration = finalCoreArmorThickness - remainingPenetration;