mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +02:00
fix: heat ricochet
This commit is contained in:
1 parent
170056cc55
commit
36f0299e51
3 files changed
+14
-2
No files matched your search
@@ -9,6 +9,7 @@ import {
|
|||||||
Vector3,
|
Vector3,
|
||||||
} from 'three';
|
} from 'three';
|
||||||
import { degToRad } from 'three/src/math/MathUtils';
|
import { degToRad } from 'three/src/math/MathUtils';
|
||||||
|
import { canRicochet } from '../../../../core/blitz/canRicochet';
|
||||||
import { canSplash } from '../../../../core/blitz/canSplash';
|
import { canSplash } from '../../../../core/blitz/canSplash';
|
||||||
import { isExplosive } from '../../../../core/blitz/isExplosive';
|
import { isExplosive } from '../../../../core/blitz/isExplosive';
|
||||||
import { resolveNearPenetration } from '../../../../core/blitz/resolveNearPenetration';
|
import { resolveNearPenetration } from '../../../../core/blitz/resolveNearPenetration';
|
||||||
@@ -43,6 +44,7 @@ export function ArmorMesh({
|
|||||||
const initialTankopedia = useTankopediaPersistent.getState();
|
const initialTankopedia = useTankopediaPersistent.getState();
|
||||||
const material = useRef<ShaderMaterial>(null);
|
const material = useRef<ShaderMaterial>(null);
|
||||||
const explosionCapable = isExplosive(initialShell.type);
|
const explosionCapable = isExplosive(initialShell.type);
|
||||||
|
const ricochetCapable = canRicochet(initialShell.type);
|
||||||
const cameraNormal = new Vector3();
|
const cameraNormal = new Vector3();
|
||||||
const shellNormal = new Vector3();
|
const shellNormal = new Vector3();
|
||||||
const surfaceNormal = new Vector3();
|
const surfaceNormal = new Vector3();
|
||||||
@@ -66,6 +68,7 @@ export function ArmorMesh({
|
|||||||
function updateShellProperties() {
|
function updateShellProperties() {
|
||||||
const shell = useDuel.getState().antagonist!.shell;
|
const shell = useDuel.getState().antagonist!.shell;
|
||||||
if (material.current) {
|
if (material.current) {
|
||||||
|
material.current.uniforms.canRicochet.value = canRicochet(shell.type);
|
||||||
material.current.uniforms.isExplosive.value = isExplosive(shell.type);
|
material.current.uniforms.isExplosive.value = isExplosive(shell.type);
|
||||||
material.current.uniforms.canSplash.value = canSplash(shell.type);
|
material.current.uniforms.canSplash.value = canSplash(shell.type);
|
||||||
material.current.uniforms.caliber.value = shell.caliber;
|
material.current.uniforms.caliber.value = shell.caliber;
|
||||||
@@ -211,7 +214,7 @@ export function ArmorMesh({
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
index === 0 &&
|
index === 0 &&
|
||||||
!isExplosive(shell.type) &&
|
canRicochet(shell.type) &&
|
||||||
!threeCalibersRule &&
|
!threeCalibersRule &&
|
||||||
angle >= degToRad(shell.ricochet!)
|
angle >= degToRad(shell.ricochet!)
|
||||||
) {
|
) {
|
||||||
@@ -319,6 +322,7 @@ export function ArmorMesh({
|
|||||||
},
|
},
|
||||||
maxThickness: { value: maxThickness },
|
maxThickness: { value: maxThickness },
|
||||||
isExplosive: { value: explosionCapable },
|
isExplosive: { value: explosionCapable },
|
||||||
|
canRicochet: { value: ricochetCapable },
|
||||||
canSplash: { value: canSplash(initialShell.type) },
|
canSplash: { value: canSplash(initialShell.type) },
|
||||||
thickness: {
|
thickness: {
|
||||||
value:
|
value:
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
varying vec3 vViewPosition;
|
varying vec3 vViewPosition;
|
||||||
varying vec3 vNormal;
|
varying vec3 vNormal;
|
||||||
uniform bool isExplosive;
|
uniform bool isExplosive;
|
||||||
|
uniform bool canRicochet;
|
||||||
uniform bool canSplash;
|
uniform bool canSplash;
|
||||||
uniform float thickness;
|
uniform float thickness;
|
||||||
uniform float penetration;
|
uniform float penetration;
|
||||||
@@ -45,7 +46,7 @@ void main() {
|
|||||||
float spacedArmorNominalThickness = spacedArmorMaskColor.g * maxThickness;
|
float spacedArmorNominalThickness = spacedArmorMaskColor.g * maxThickness;
|
||||||
bool spacedArmorThreeCalibersRule = isUnderSpacedArmor && caliber > 3.0 * spacedArmorNominalThickness;
|
bool spacedArmorThreeCalibersRule = isUnderSpacedArmor && caliber > 3.0 * spacedArmorNominalThickness;
|
||||||
bool hasRicochetedSpacedArmor = isUnderSpacedArmor && !spacedArmorThreeCalibersRule && spacedArmorAngle >= ricochetAngle;
|
bool hasRicochetedSpacedArmor = isUnderSpacedArmor && !spacedArmorThreeCalibersRule && spacedArmorAngle >= ricochetAngle;
|
||||||
bool hasRicochetedCoreArmor = !hasRicochetedSpacedArmor && !isUnderExternalModule && !isExplosive && !coreArmorThreeCalibersRule && coreArmorangle >= ricochetAngle;
|
bool hasRicochetedCoreArmor = !hasRicochetedSpacedArmor && !isUnderExternalModule && canRicochet && !coreArmorThreeCalibersRule && coreArmorangle >= ricochetAngle;
|
||||||
|
|
||||||
if (hasRicochetedCoreArmor || hasRicochetedSpacedArmor) {
|
if (hasRicochetedCoreArmor || hasRicochetedSpacedArmor) {
|
||||||
penetrationChance = 0.0;
|
penetrationChance = 0.0;
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import { ShellDefinition } from '../blitzkrieg/tankDefinitions';
|
||||||
|
|
||||||
|
export function canRicochet(
|
||||||
|
type: ShellDefinition['type'],
|
||||||
|
): type is Exclude<ShellDefinition['type'], 'he'> {
|
||||||
|
return type !== 'he';
|
||||||
|
}
|
||||||
Reference in new issue
Block a user