mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
fix: division by 0
This commit is contained in:
1 parent
0e57c37296
commit
c128d8ab0c
2 files changed
+9
-8
No files matched your search
@@ -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));
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user