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