mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
fix: unified max thicknesses
This commit is contained in:
1 parent
c56eaa258d
commit
8199bd550d
8 files changed
+26
-37
No files matched your search
@@ -20,6 +20,8 @@ export async function buildTankArmors() {
|
||||
|
||||
await Promise.all(
|
||||
nations.map(async (nation) => {
|
||||
if (nation !== 'japan') return;
|
||||
|
||||
const tanks = await readXMLDVPL<{ root: VehicleDefinitionList }>(
|
||||
`${DATA}/${POI.vehicleDefinitions}/${nation}/list.xml.dvpl`,
|
||||
);
|
||||
@@ -28,8 +30,6 @@ export async function buildTankArmors() {
|
||||
Object.entries(tanks.root).map(async ([tankKey, tank]) => {
|
||||
const id = toUniqueId(nation, tank.id);
|
||||
|
||||
if (id !== 9489) return;
|
||||
|
||||
console.log(`Building armor ${id} @ ${nation}/${tankKey}`);
|
||||
|
||||
const model = await extractArmor(DATA, `${nation}-${tankKey}`);
|
||||
|
||||
@@ -27,6 +27,8 @@ export async function buildTankModels() {
|
||||
|
||||
await Promise.all(
|
||||
nations.map(async (nation) => {
|
||||
if (nation !== 'japan') return;
|
||||
|
||||
const tanks = await readXMLDVPL<{ root: VehicleDefinitionList }>(
|
||||
`${DATA}/${POI.vehicleDefinitions}/${nation}/list.xml.dvpl`,
|
||||
);
|
||||
@@ -43,8 +45,6 @@ export async function buildTankModels() {
|
||||
Object.entries(tanks.root).map(async ([tankKey, tank]) => {
|
||||
const id = toUniqueId(nation, tank.id);
|
||||
|
||||
if (id !== 9489) return;
|
||||
|
||||
console.log(`Building model ${id} @ ${nation}/${tankKey}`);
|
||||
|
||||
const parameters = await readYAMLDVPL<TankParameters>(
|
||||
|
||||
+5
-15
@@ -123,20 +123,13 @@ export function ArmorHighlighting({ duel }: ArmorHighlightingProps) {
|
||||
turretModelDefinition.gunOrigin[1],
|
||||
-turretModelDefinition.gunOrigin[2],
|
||||
).applyAxisAngle(X_AXIS, Math.PI / 2);
|
||||
const maxExternalModuleThickness = Math.max(
|
||||
const maxThickness = Math.max(
|
||||
tankModelDefinition.trackThickness,
|
||||
gunModelDefinition.barrelThickness,
|
||||
);
|
||||
const maxSpacedArmorThickness = Math.max(
|
||||
...armorNodes
|
||||
.map((node) => {
|
||||
const armorId = nameToArmorId(node.name);
|
||||
const { spaced, thickness } = resolveArmor(
|
||||
tankModelDefinition.armor,
|
||||
armorId,
|
||||
);
|
||||
|
||||
return spaced ? thickness : null;
|
||||
return resolveArmor(tankModelDefinition.armor, armorId).thickness;
|
||||
})
|
||||
.filter(Boolean),
|
||||
);
|
||||
@@ -160,8 +153,7 @@ export function ArmorHighlighting({ duel }: ArmorHighlightingProps) {
|
||||
|
||||
return (
|
||||
<ArmorMesh
|
||||
maxExternalModuleThickness={maxExternalModuleThickness}
|
||||
maxSpacedArmorThickness={maxSpacedArmorThickness}
|
||||
maxThickness={maxThickness}
|
||||
duel={duel}
|
||||
key={node.uuid}
|
||||
geometry={(node as Mesh).geometry}
|
||||
@@ -186,8 +178,7 @@ export function ArmorHighlighting({ duel }: ArmorHighlightingProps) {
|
||||
|
||||
return (
|
||||
<ArmorMesh
|
||||
maxExternalModuleThickness={maxExternalModuleThickness}
|
||||
maxSpacedArmorThickness={maxSpacedArmorThickness}
|
||||
maxThickness={maxThickness}
|
||||
duel={duel}
|
||||
key={node.uuid}
|
||||
geometry={(node as Mesh).geometry}
|
||||
@@ -212,8 +203,7 @@ export function ArmorHighlighting({ duel }: ArmorHighlightingProps) {
|
||||
|
||||
return (
|
||||
<ArmorMesh
|
||||
maxExternalModuleThickness={maxExternalModuleThickness}
|
||||
maxSpacedArmorThickness={maxSpacedArmorThickness}
|
||||
maxThickness={maxThickness}
|
||||
duel={duel}
|
||||
key={node.uuid}
|
||||
geometry={(node as Mesh).geometry}
|
||||
|
||||
+7
-1
@@ -25,7 +25,7 @@ interface ExternalModuleMaskProps {
|
||||
|
||||
/**
|
||||
* When rendered, generates a mask and thickness buffer for external modules.
|
||||
* - R: 0 means not external module
|
||||
* - R: 1 means external module
|
||||
* - G: normalized thickness; multiply with max thickness to get nominal thickness
|
||||
* - B: no data
|
||||
* - A: 1 means is armor; 0 is background
|
||||
@@ -126,6 +126,12 @@ export const ExternalModuleMask = memo<ExternalModuleMaskProps>(({ duel }) => {
|
||||
const maxThickness = Math.max(
|
||||
tankModelDefinition.trackThickness,
|
||||
gunModelDefinition.barrelThickness,
|
||||
...armorNodes
|
||||
.map((node) => {
|
||||
const armorId = nameToArmorId(node.name);
|
||||
return resolveArmor(tankModelDefinition.armor, armorId).thickness;
|
||||
})
|
||||
.filter(Boolean),
|
||||
);
|
||||
const turretOrigin = new Vector3(
|
||||
tankModelDefinition.turretOrigin[0],
|
||||
|
||||
+3
-6
@@ -130,15 +130,12 @@ export const SpacedArmorDepth = memo<SpacedArmorDepthProps>(({ duel }) => {
|
||||
const gunModelDefinition =
|
||||
turretModelDefinition.guns[duel.protagonist.gun.id];
|
||||
const maxThickness = Math.max(
|
||||
tankModelDefinition.trackThickness,
|
||||
gunModelDefinition.barrelThickness,
|
||||
...armorNodes
|
||||
.map((node) => {
|
||||
const armorId = nameToArmorId(node.name);
|
||||
const { spaced, thickness } = resolveArmor(
|
||||
tankModelDefinition.armor,
|
||||
armorId,
|
||||
);
|
||||
|
||||
return spaced ? thickness : null;
|
||||
return resolveArmor(tankModelDefinition.armor, armorId).thickness;
|
||||
})
|
||||
.filter(Boolean),
|
||||
);
|
||||
|
||||
@@ -17,15 +17,13 @@ interface ArmorMeshProps extends MeshProps {
|
||||
duel: Duel;
|
||||
isExternalModule?: boolean;
|
||||
thickness: number;
|
||||
maxExternalModuleThickness: number;
|
||||
maxSpacedArmorThickness: number;
|
||||
maxThickness: number;
|
||||
}
|
||||
|
||||
export function ArmorMesh({
|
||||
isExternalModule = false,
|
||||
thickness,
|
||||
maxExternalModuleThickness,
|
||||
maxSpacedArmorThickness,
|
||||
maxThickness,
|
||||
duel,
|
||||
...props
|
||||
}: ArmorMeshProps) {
|
||||
@@ -78,8 +76,7 @@ export function ArmorMesh({
|
||||
zNear: { value: camera.near },
|
||||
zFar: { value: camera.far },
|
||||
greenPenetration: { value: greenPenetration },
|
||||
maxExternalModuleThickness: { value: maxExternalModuleThickness },
|
||||
maxSpacedArmorThickness: { value: maxSpacedArmorThickness },
|
||||
maxThickness: { value: maxThickness },
|
||||
isExplosive: { value: isExplosive(shell.type) },
|
||||
canSplash: { value: canSplash(shell.type) },
|
||||
isExternalModule: { value: isExternalModule },
|
||||
|
||||
@@ -12,8 +12,7 @@ uniform sampler2D spacedArmorDepth;
|
||||
uniform sampler2D spacedArmorMask;
|
||||
uniform vec2 resolution;
|
||||
varying mat4 vProjectionMatrix;
|
||||
uniform float maxExternalModuleThickness;
|
||||
uniform float maxSpacedArmorThickness;
|
||||
uniform float maxThickness;
|
||||
uniform bool greenPenetration;
|
||||
|
||||
float depthToDistance(float depth) {
|
||||
@@ -46,7 +45,7 @@ void main() {
|
||||
float splashChance = -1.0;
|
||||
bool threeCalibersRule = caliber > 3.0 * thickness;
|
||||
float normalizedSpacedArmorThickness = spacedArmorMaskColor.g;
|
||||
float spacedArmorNominalThickness = normalizedSpacedArmorThickness * maxSpacedArmorThickness;
|
||||
float spacedArmorNominalThickness = normalizedSpacedArmorThickness * maxThickness;
|
||||
bool spadedArmorThreeCalibersRule = isUnderSpacedArmor && caliber > 3.0 * spacedArmorNominalThickness;
|
||||
bool ricochetSpacedArmor = isUnderSpacedArmor && !spadedArmorThreeCalibersRule && spacedArmorAngle >= ricochet;
|
||||
bool ricochetCoreArmor = !ricochetSpacedArmor && !isUnderExternalModule && !isExternalModule && !isExplosive && !threeCalibersRule && angle >= ricochet;
|
||||
@@ -59,7 +58,7 @@ void main() {
|
||||
|
||||
if (isUnderExternalModule) {
|
||||
float normalizedExternalModuleThickness = externalModuleMaskColor.g;
|
||||
float externalModuleThickness = normalizedExternalModuleThickness * maxExternalModuleThickness;
|
||||
float externalModuleThickness = normalizedExternalModuleThickness * maxThickness;
|
||||
piercedPenetration -= externalModuleThickness;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,5 +8,5 @@ void main() {
|
||||
float dotProduct = dot(normalizedNormal, -normalizedViewPosition);
|
||||
float angle = acos(dotProduct);
|
||||
|
||||
csm_FragColor = vec4(angle / PI, thickness / maxThickness, 0.0, 1.0);
|
||||
csm_FragColor = vec4(angle / (PI / 2.0), thickness / maxThickness, 0.0, 1.0);
|
||||
}
|
||||
Reference in new issue
Block a user