fix(wireframe): 按新版字段修复模型采集与敌我判定
This commit is contained in:
1 parent
4d8cbd81d6
commit
86b9322a9f
4 files changed
+234
-147
No files matched your search
@@ -229,15 +229,25 @@
|
|||||||
var ZCt = null, m2Fn = null;
|
var ZCt = null, m2Fn = null;
|
||||||
|
|
||||||
// 加载队伍判断函数(从 module_87072 导出)
|
// 加载队伍判断函数(从 module_87072 导出)
|
||||||
// ZCt (mod.$_$.kd): 从坦克对象获取队伍ID
|
// 新旧差异(main.7cfa4058):
|
||||||
// m2 (mod.$_$.rk): 判断两个队伍ID是否相同且非中立 = t.equals(n) && !t.equals(E$())
|
// 取队伍 $_$.vd = WIt(t) → g$(HIt(), t).b135_1(坦克无队伍时返回中立 q$())
|
||||||
|
// 同队判定 $_$.dl = R7(a, b) → a.equals(b) && !a.equals(q$())
|
||||||
|
// ⚠ 旧键 $_$.kd / $_$.rk 在新版已指向无关的构造器类(CCt / FIn),用了会"敌我不分"
|
||||||
|
var TEAM_GET_KEYS = ['vd', 'kd'];
|
||||||
|
var TEAM_EQ_KEYS = ['dl', 'rk'];
|
||||||
function LoadTeamFunctions() {
|
function LoadTeamFunctions() {
|
||||||
if (ZCt && m2Fn) return { ZCt: ZCt, m2Fn: m2Fn };
|
if (ZCt && m2Fn) return { ZCt: ZCt, m2Fn: m2Fn };
|
||||||
try {
|
try {
|
||||||
var mod87072 = window.__wp_require__(87072);
|
var mod87072 = window.__wp_require__(87072);
|
||||||
if (mod87072 && mod87072.$_$) {
|
if (mod87072 && mod87072.$_$) {
|
||||||
ZCt = mod87072.$_$.kd;
|
for (var i = 0; i < TEAM_GET_KEYS.length && !ZCt; i++) {
|
||||||
m2Fn = mod87072.$_$.rk;
|
var G = mod87072.$_$[TEAM_GET_KEYS[i]];
|
||||||
|
if (typeof G === 'function') ZCt = G;
|
||||||
|
}
|
||||||
|
for (var j = 0; j < TEAM_EQ_KEYS.length && !m2Fn; j++) {
|
||||||
|
var E = mod87072.$_$[TEAM_EQ_KEYS[j]];
|
||||||
|
if (typeof E === 'function') m2Fn = E;
|
||||||
|
}
|
||||||
console.log('[公共库] 队伍判断函数已加载: ZCt=' + (typeof ZCt) + ', m2=' + (typeof m2Fn));
|
console.log('[公共库] 队伍判断函数已加载: ZCt=' + (typeof ZCt) + ', m2=' + (typeof m2Fn));
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
@@ -1735,36 +1745,47 @@
|
|||||||
return vc;
|
return vc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== 获取 KMt / TDt 渲染组件 =====
|
// ===== 皮肤组件(新旧差异修正) =====
|
||||||
// 新 build:车身皮肤组件字段是 w14w_1(kDt(t)=t.w14w_1,缺失报 "skin";RDt.j16r 里赋值)
|
// 新版(main.7cfa4058):
|
||||||
// 旧 build:w14x_1 / t14l_1 / p14l_1(新版 t14l_1 已改成悬停车体状态 Qmt,务必别再当皮肤用)
|
// skin 组件(类 eUt)构造后由 j16r 把皮肤对象存到 **组件自己的 g159_1**,
|
||||||
function GetKMtComponent(entity) {
|
// 皮肤对象.g17r_1 = 车身部件表;每个部件 part.j17r_1 是**单个 BP 节点**(旧版是节点列表)。
|
||||||
var comp = FindComponentByField(entity, 'w14w_1');
|
// 炮塔根节点 = skinComp.a17q_1(weaponSkin 组件 LUt.u11p() = e13a().a17q_1,e13a 取的就是 skin 组件)。
|
||||||
|
// 旧写法(w14w_1 / n11c_1 / m17a_1)在新版已被无关类占用(w14w_1=SetReverseBackTurn、m17a_1=数值参数),不再可用。
|
||||||
|
function GetSkinComponent(entity) {
|
||||||
|
var comp = FindComponentByField(entity, 'g159_1');
|
||||||
if (comp) return comp;
|
if (comp) return comp;
|
||||||
comp = FindComponentByField(entity, 'w14x_1');
|
comp = FindComponentByField(entity, 'a17q_1');
|
||||||
if (comp) return comp;
|
|
||||||
comp = FindComponentByField(entity, 't14l_1');
|
|
||||||
if (comp) return comp;
|
|
||||||
comp = FindComponentByField(entity, 'p14l_1');
|
|
||||||
return comp;
|
return comp;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 取车身皮肤对象(含 g17r_1 部件表),跨版本兼容;stats 用于诊断来源
|
// 取车身皮肤对象(含 g17r_1 部件表);stats 用于诊断来源
|
||||||
function GetHullSkin(tank, stats) {
|
function GetHullSkin(tank, stats) {
|
||||||
var comp = GetKMtComponent(tank);
|
var comp = GetSkinComponent(tank);
|
||||||
if (!comp) { if (stats) stats.hullSource = '无组件'; return null; }
|
if (!comp) { if (stats) stats.hullSource = '无皮肤组件'; return null; }
|
||||||
if (comp.w14w_1 && comp.w14w_1.g17r_1) { if (stats) stats.hullSource = 'w14w_1'; return comp.w14w_1; } // 新 build
|
if (comp.g159_1 && comp.g159_1.g17r_1) { if (stats) stats.hullSource = 'g159_1'; return comp.g159_1; }
|
||||||
if (comp.t14l_1 && comp.t14l_1.g17r_1) { if (stats) stats.hullSource = 't14l_1'; return comp.t14l_1; } // 旧 build
|
|
||||||
if (comp.p14l_1 && comp.p14l_1.g17r_1) { if (stats) stats.hullSource = 'p14l_1'; return comp.p14l_1; } // 旧 build
|
|
||||||
if (stats) stats.hullSource = '有组件但无皮肤';
|
if (stats) stats.hullSource = '有组件但无皮肤';
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function GetTDtComponent(entity) {
|
// 炮塔 BP 根节点
|
||||||
var comp = FindComponentByField(entity, 'n11c_1');
|
function GetTurretNode(entity) {
|
||||||
if (comp) return comp;
|
var comp = GetSkinComponent(entity);
|
||||||
comp = FindComponentByField(entity, 'q112_1');
|
return (comp && comp.a17q_1) ? comp.a17q_1 : null;
|
||||||
return comp;
|
}
|
||||||
|
|
||||||
|
// 兼容两种集合:引擎列表类(e1/g1)与迭代器(t/u/v)
|
||||||
|
function ForEachInList(list, fn) {
|
||||||
|
if (!list) return;
|
||||||
|
try {
|
||||||
|
if (typeof list.e1 === 'function' && typeof list.g1 === 'function') {
|
||||||
|
var n = list.e1();
|
||||||
|
for (var i = 0; i < n; i++) fn(list.g1(i));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (typeof list.t === 'function') {
|
||||||
|
for (var it = list.t(); it.u();) fn(it.v());
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== 从GPU读取顶点位置数据(缓冲区[0]) =====
|
// ===== 从GPU读取顶点位置数据(缓冲区[0]) =====
|
||||||
@@ -1887,14 +1908,14 @@
|
|||||||
}
|
}
|
||||||
} catch(e) {}
|
} catch(e) {}
|
||||||
}
|
}
|
||||||
if (bpNode.p35_1 && typeof bpNode.p35_1.e1 === 'function') {
|
// 子节点:新版是 r35_1(zl 基类:this.r35_1 = new lo(),r3k 里递归子节点)
|
||||||
var childCount = bpNode.p35_1.e1();
|
// 旧版是 p35_1;新版 p35_1 已变成"世界矩阵",绝不能当子节点列表
|
||||||
for (var c = 0; c < childCount; c++) {
|
var Children = (bpNode.r35_1 && typeof bpNode.r35_1.e1 === 'function') ? bpNode.r35_1 :
|
||||||
try {
|
((bpNode.p35_1 && typeof bpNode.p35_1.e1 === 'function') ? bpNode.p35_1 : null);
|
||||||
var child = bpNode.p35_1.g1(c);
|
if (Children) {
|
||||||
if (child) CollectMeshNodes(child, nodes, depth + 1, group, stats);
|
ForEachInList(Children, function (child) {
|
||||||
} catch(e) {}
|
if (child) CollectMeshNodes(child, nodes, depth + 1, group, stats);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1904,25 +1925,27 @@
|
|||||||
var skin = GetHullSkin(tank, stats);
|
var skin = GetHullSkin(tank, stats);
|
||||||
if (skin) {
|
if (skin) {
|
||||||
try {
|
try {
|
||||||
var partCount = skin.g17r_1.e1();
|
if (stats) stats.hullParts = (typeof skin.g17r_1.e1 === 'function') ? skin.g17r_1.e1() : -1;
|
||||||
if (stats) stats.hullParts = partCount;
|
ForEachInList(skin.g17r_1, function (part) {
|
||||||
for (var p = 0; p < partCount; p++) {
|
if (!part) return;
|
||||||
var part = skin.g17r_1.g1(p);
|
// 新版:part.j17r_1 是单个 BP 节点;旧版是节点列表
|
||||||
if (!part || !part.j17r_1) continue;
|
var j = part.j17r_1;
|
||||||
var nodeCount = part.j17r_1.e1();
|
if (!j) return;
|
||||||
for (var n = 0; n < nodeCount; n++) {
|
if (typeof j === 'object' && typeof j.e1 === 'function' && typeof j.g1 === 'function') {
|
||||||
var bpNode = part.j17r_1.g1(n);
|
ForEachInList(j, function (bp) {
|
||||||
if (!bpNode) continue;
|
if (bp) CollectMeshNodes(bp, nodes, 0, 'hull', stats ? stats.hull : null);
|
||||||
CollectMeshNodes(bpNode, nodes, 0, 'hull', stats ? stats.hull : null);
|
});
|
||||||
|
} else {
|
||||||
|
CollectMeshNodes(j, nodes, 0, 'hull', stats ? stats.hull : null);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
} catch(e) {}
|
} catch(e) {}
|
||||||
}
|
}
|
||||||
var tdt = GetTDtComponent(tank);
|
var turretNode = GetTurretNode(tank);
|
||||||
if (stats) stats.turretComp = !!tdt;
|
if (stats) stats.turretComp = !!turretNode;
|
||||||
if (tdt && tdt.n11c_1 && tdt.n11c_1.m17a_1) {
|
if (turretNode) {
|
||||||
if (stats) stats.turretRoot = true;
|
if (stats) stats.turretRoot = true;
|
||||||
try { CollectMeshNodes(tdt.n11c_1.m17a_1, nodes, 0, 'turret', stats ? stats.turret : null); } catch(e) {}
|
try { CollectMeshNodes(turretNode, nodes, 0, 'turret', stats ? stats.turret : null); } catch(e) {}
|
||||||
}
|
}
|
||||||
return nodes;
|
return nodes;
|
||||||
}
|
}
|
||||||
@@ -1940,7 +1963,13 @@
|
|||||||
var NodeMatrixScratch = new Float32Array(16);
|
var NodeMatrixScratch = new Float32Array(16);
|
||||||
|
|
||||||
function IsNodeValid(bpNode, pos, tankIsMoving, diagStats) {
|
function IsNodeValid(bpNode, pos, tankIsMoving, diagStats) {
|
||||||
var M = bpNode.n35_1;
|
// 世界矩阵:新版是 p35_1(zl 基类构造里 = hl(),s3k/t3k/u3k 读 p35_1[12..14])
|
||||||
|
// 旧版是 n35_1;新版 n35_1 已变成布尔标志
|
||||||
|
var M = bpNode.p35_1;
|
||||||
|
if (!M || typeof M.length !== 'number' || M.length < 16) {
|
||||||
|
var OldM = bpNode.n35_1;
|
||||||
|
M = (OldM && typeof OldM.length === 'number' && OldM.length >= 16) ? OldM : null;
|
||||||
|
}
|
||||||
if (!M) return null;
|
if (!M) return null;
|
||||||
if (diagStats) diagStats.totalNodes++;
|
if (diagStats) diagStats.totalNodes++;
|
||||||
|
|
||||||
|
|||||||
+78
-49
@@ -229,15 +229,25 @@
|
|||||||
var ZCt = null, m2Fn = null;
|
var ZCt = null, m2Fn = null;
|
||||||
|
|
||||||
// 加载队伍判断函数(从 module_87072 导出)
|
// 加载队伍判断函数(从 module_87072 导出)
|
||||||
// ZCt (mod.$_$.kd): 从坦克对象获取队伍ID
|
// 新旧差异(main.7cfa4058):
|
||||||
// m2 (mod.$_$.rk): 判断两个队伍ID是否相同且非中立 = t.equals(n) && !t.equals(E$())
|
// 取队伍 $_$.vd = WIt(t) → g$(HIt(), t).b135_1(坦克无队伍时返回中立 q$())
|
||||||
|
// 同队判定 $_$.dl = R7(a, b) → a.equals(b) && !a.equals(q$())
|
||||||
|
// ⚠ 旧键 $_$.kd / $_$.rk 在新版已指向无关的构造器类(CCt / FIn),用了会"敌我不分"
|
||||||
|
var TEAM_GET_KEYS = ['vd', 'kd'];
|
||||||
|
var TEAM_EQ_KEYS = ['dl', 'rk'];
|
||||||
function LoadTeamFunctions() {
|
function LoadTeamFunctions() {
|
||||||
if (ZCt && m2Fn) return { ZCt: ZCt, m2Fn: m2Fn };
|
if (ZCt && m2Fn) return { ZCt: ZCt, m2Fn: m2Fn };
|
||||||
try {
|
try {
|
||||||
var mod87072 = window.__wp_require__(87072);
|
var mod87072 = window.__wp_require__(87072);
|
||||||
if (mod87072 && mod87072.$_$) {
|
if (mod87072 && mod87072.$_$) {
|
||||||
ZCt = mod87072.$_$.kd;
|
for (var i = 0; i < TEAM_GET_KEYS.length && !ZCt; i++) {
|
||||||
m2Fn = mod87072.$_$.rk;
|
var G = mod87072.$_$[TEAM_GET_KEYS[i]];
|
||||||
|
if (typeof G === 'function') ZCt = G;
|
||||||
|
}
|
||||||
|
for (var j = 0; j < TEAM_EQ_KEYS.length && !m2Fn; j++) {
|
||||||
|
var E = mod87072.$_$[TEAM_EQ_KEYS[j]];
|
||||||
|
if (typeof E === 'function') m2Fn = E;
|
||||||
|
}
|
||||||
console.log('[公共库] 队伍判断函数已加载: ZCt=' + (typeof ZCt) + ', m2=' + (typeof m2Fn));
|
console.log('[公共库] 队伍判断函数已加载: ZCt=' + (typeof ZCt) + ', m2=' + (typeof m2Fn));
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
@@ -1735,36 +1745,47 @@
|
|||||||
return vc;
|
return vc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== 获取 KMt / TDt 渲染组件 =====
|
// ===== 皮肤组件(新旧差异修正) =====
|
||||||
// 新 build:车身皮肤组件字段是 w14w_1(kDt(t)=t.w14w_1,缺失报 "skin";RDt.j16r 里赋值)
|
// 新版(main.7cfa4058):
|
||||||
// 旧 build:w14x_1 / t14l_1 / p14l_1(新版 t14l_1 已改成悬停车体状态 Qmt,务必别再当皮肤用)
|
// skin 组件(类 eUt)构造后由 j16r 把皮肤对象存到 **组件自己的 g159_1**,
|
||||||
function GetKMtComponent(entity) {
|
// 皮肤对象.g17r_1 = 车身部件表;每个部件 part.j17r_1 是**单个 BP 节点**(旧版是节点列表)。
|
||||||
var comp = FindComponentByField(entity, 'w14w_1');
|
// 炮塔根节点 = skinComp.a17q_1(weaponSkin 组件 LUt.u11p() = e13a().a17q_1,e13a 取的就是 skin 组件)。
|
||||||
|
// 旧写法(w14w_1 / n11c_1 / m17a_1)在新版已被无关类占用(w14w_1=SetReverseBackTurn、m17a_1=数值参数),不再可用。
|
||||||
|
function GetSkinComponent(entity) {
|
||||||
|
var comp = FindComponentByField(entity, 'g159_1');
|
||||||
if (comp) return comp;
|
if (comp) return comp;
|
||||||
comp = FindComponentByField(entity, 'w14x_1');
|
comp = FindComponentByField(entity, 'a17q_1');
|
||||||
if (comp) return comp;
|
|
||||||
comp = FindComponentByField(entity, 't14l_1');
|
|
||||||
if (comp) return comp;
|
|
||||||
comp = FindComponentByField(entity, 'p14l_1');
|
|
||||||
return comp;
|
return comp;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 取车身皮肤对象(含 g17r_1 部件表),跨版本兼容;stats 用于诊断来源
|
// 取车身皮肤对象(含 g17r_1 部件表);stats 用于诊断来源
|
||||||
function GetHullSkin(tank, stats) {
|
function GetHullSkin(tank, stats) {
|
||||||
var comp = GetKMtComponent(tank);
|
var comp = GetSkinComponent(tank);
|
||||||
if (!comp) { if (stats) stats.hullSource = '无组件'; return null; }
|
if (!comp) { if (stats) stats.hullSource = '无皮肤组件'; return null; }
|
||||||
if (comp.w14w_1 && comp.w14w_1.g17r_1) { if (stats) stats.hullSource = 'w14w_1'; return comp.w14w_1; } // 新 build
|
if (comp.g159_1 && comp.g159_1.g17r_1) { if (stats) stats.hullSource = 'g159_1'; return comp.g159_1; }
|
||||||
if (comp.t14l_1 && comp.t14l_1.g17r_1) { if (stats) stats.hullSource = 't14l_1'; return comp.t14l_1; } // 旧 build
|
|
||||||
if (comp.p14l_1 && comp.p14l_1.g17r_1) { if (stats) stats.hullSource = 'p14l_1'; return comp.p14l_1; } // 旧 build
|
|
||||||
if (stats) stats.hullSource = '有组件但无皮肤';
|
if (stats) stats.hullSource = '有组件但无皮肤';
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function GetTDtComponent(entity) {
|
// 炮塔 BP 根节点
|
||||||
var comp = FindComponentByField(entity, 'n11c_1');
|
function GetTurretNode(entity) {
|
||||||
if (comp) return comp;
|
var comp = GetSkinComponent(entity);
|
||||||
comp = FindComponentByField(entity, 'q112_1');
|
return (comp && comp.a17q_1) ? comp.a17q_1 : null;
|
||||||
return comp;
|
}
|
||||||
|
|
||||||
|
// 兼容两种集合:引擎列表类(e1/g1)与迭代器(t/u/v)
|
||||||
|
function ForEachInList(list, fn) {
|
||||||
|
if (!list) return;
|
||||||
|
try {
|
||||||
|
if (typeof list.e1 === 'function' && typeof list.g1 === 'function') {
|
||||||
|
var n = list.e1();
|
||||||
|
for (var i = 0; i < n; i++) fn(list.g1(i));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (typeof list.t === 'function') {
|
||||||
|
for (var it = list.t(); it.u();) fn(it.v());
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== 从GPU读取顶点位置数据(缓冲区[0]) =====
|
// ===== 从GPU读取顶点位置数据(缓冲区[0]) =====
|
||||||
@@ -1887,14 +1908,14 @@
|
|||||||
}
|
}
|
||||||
} catch(e) {}
|
} catch(e) {}
|
||||||
}
|
}
|
||||||
if (bpNode.p35_1 && typeof bpNode.p35_1.e1 === 'function') {
|
// 子节点:新版是 r35_1(zl 基类:this.r35_1 = new lo(),r3k 里递归子节点)
|
||||||
var childCount = bpNode.p35_1.e1();
|
// 旧版是 p35_1;新版 p35_1 已变成"世界矩阵",绝不能当子节点列表
|
||||||
for (var c = 0; c < childCount; c++) {
|
var Children = (bpNode.r35_1 && typeof bpNode.r35_1.e1 === 'function') ? bpNode.r35_1 :
|
||||||
try {
|
((bpNode.p35_1 && typeof bpNode.p35_1.e1 === 'function') ? bpNode.p35_1 : null);
|
||||||
var child = bpNode.p35_1.g1(c);
|
if (Children) {
|
||||||
if (child) CollectMeshNodes(child, nodes, depth + 1, group, stats);
|
ForEachInList(Children, function (child) {
|
||||||
} catch(e) {}
|
if (child) CollectMeshNodes(child, nodes, depth + 1, group, stats);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1904,25 +1925,27 @@
|
|||||||
var skin = GetHullSkin(tank, stats);
|
var skin = GetHullSkin(tank, stats);
|
||||||
if (skin) {
|
if (skin) {
|
||||||
try {
|
try {
|
||||||
var partCount = skin.g17r_1.e1();
|
if (stats) stats.hullParts = (typeof skin.g17r_1.e1 === 'function') ? skin.g17r_1.e1() : -1;
|
||||||
if (stats) stats.hullParts = partCount;
|
ForEachInList(skin.g17r_1, function (part) {
|
||||||
for (var p = 0; p < partCount; p++) {
|
if (!part) return;
|
||||||
var part = skin.g17r_1.g1(p);
|
// 新版:part.j17r_1 是单个 BP 节点;旧版是节点列表
|
||||||
if (!part || !part.j17r_1) continue;
|
var j = part.j17r_1;
|
||||||
var nodeCount = part.j17r_1.e1();
|
if (!j) return;
|
||||||
for (var n = 0; n < nodeCount; n++) {
|
if (typeof j === 'object' && typeof j.e1 === 'function' && typeof j.g1 === 'function') {
|
||||||
var bpNode = part.j17r_1.g1(n);
|
ForEachInList(j, function (bp) {
|
||||||
if (!bpNode) continue;
|
if (bp) CollectMeshNodes(bp, nodes, 0, 'hull', stats ? stats.hull : null);
|
||||||
CollectMeshNodes(bpNode, nodes, 0, 'hull', stats ? stats.hull : null);
|
});
|
||||||
|
} else {
|
||||||
|
CollectMeshNodes(j, nodes, 0, 'hull', stats ? stats.hull : null);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
} catch(e) {}
|
} catch(e) {}
|
||||||
}
|
}
|
||||||
var tdt = GetTDtComponent(tank);
|
var turretNode = GetTurretNode(tank);
|
||||||
if (stats) stats.turretComp = !!tdt;
|
if (stats) stats.turretComp = !!turretNode;
|
||||||
if (tdt && tdt.n11c_1 && tdt.n11c_1.m17a_1) {
|
if (turretNode) {
|
||||||
if (stats) stats.turretRoot = true;
|
if (stats) stats.turretRoot = true;
|
||||||
try { CollectMeshNodes(tdt.n11c_1.m17a_1, nodes, 0, 'turret', stats ? stats.turret : null); } catch(e) {}
|
try { CollectMeshNodes(turretNode, nodes, 0, 'turret', stats ? stats.turret : null); } catch(e) {}
|
||||||
}
|
}
|
||||||
return nodes;
|
return nodes;
|
||||||
}
|
}
|
||||||
@@ -1940,7 +1963,13 @@
|
|||||||
var NodeMatrixScratch = new Float32Array(16);
|
var NodeMatrixScratch = new Float32Array(16);
|
||||||
|
|
||||||
function IsNodeValid(bpNode, pos, tankIsMoving, diagStats) {
|
function IsNodeValid(bpNode, pos, tankIsMoving, diagStats) {
|
||||||
var M = bpNode.n35_1;
|
// 世界矩阵:新版是 p35_1(zl 基类构造里 = hl(),s3k/t3k/u3k 读 p35_1[12..14])
|
||||||
|
// 旧版是 n35_1;新版 n35_1 已变成布尔标志
|
||||||
|
var M = bpNode.p35_1;
|
||||||
|
if (!M || typeof M.length !== 'number' || M.length < 16) {
|
||||||
|
var OldM = bpNode.n35_1;
|
||||||
|
M = (OldM && typeof OldM.length === 'number' && OldM.length >= 16) ? OldM : null;
|
||||||
|
}
|
||||||
if (!M) return null;
|
if (!M) return null;
|
||||||
if (diagStats) diagStats.totalNodes++;
|
if (diagStats) diagStats.totalNodes++;
|
||||||
|
|
||||||
|
|||||||
@@ -220,36 +220,47 @@
|
|||||||
return vc;
|
return vc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== 获取 KMt / TDt 渲染组件 =====
|
// ===== 皮肤组件(新旧差异修正) =====
|
||||||
// 新 build:车身皮肤组件字段是 w14w_1(kDt(t)=t.w14w_1,缺失报 "skin";RDt.j16r 里赋值)
|
// 新版(main.7cfa4058):
|
||||||
// 旧 build:w14x_1 / t14l_1 / p14l_1(新版 t14l_1 已改成悬停车体状态 Qmt,务必别再当皮肤用)
|
// skin 组件(类 eUt)构造后由 j16r 把皮肤对象存到 **组件自己的 g159_1**,
|
||||||
function GetKMtComponent(entity) {
|
// 皮肤对象.g17r_1 = 车身部件表;每个部件 part.j17r_1 是**单个 BP 节点**(旧版是节点列表)。
|
||||||
var comp = FindComponentByField(entity, 'w14w_1');
|
// 炮塔根节点 = skinComp.a17q_1(weaponSkin 组件 LUt.u11p() = e13a().a17q_1,e13a 取的就是 skin 组件)。
|
||||||
|
// 旧写法(w14w_1 / n11c_1 / m17a_1)在新版已被无关类占用(w14w_1=SetReverseBackTurn、m17a_1=数值参数),不再可用。
|
||||||
|
function GetSkinComponent(entity) {
|
||||||
|
var comp = FindComponentByField(entity, 'g159_1');
|
||||||
if (comp) return comp;
|
if (comp) return comp;
|
||||||
comp = FindComponentByField(entity, 'w14x_1');
|
comp = FindComponentByField(entity, 'a17q_1');
|
||||||
if (comp) return comp;
|
|
||||||
comp = FindComponentByField(entity, 't14l_1');
|
|
||||||
if (comp) return comp;
|
|
||||||
comp = FindComponentByField(entity, 'p14l_1');
|
|
||||||
return comp;
|
return comp;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 取车身皮肤对象(含 g17r_1 部件表),跨版本兼容;stats 用于诊断来源
|
// 取车身皮肤对象(含 g17r_1 部件表);stats 用于诊断来源
|
||||||
function GetHullSkin(tank, stats) {
|
function GetHullSkin(tank, stats) {
|
||||||
var comp = GetKMtComponent(tank);
|
var comp = GetSkinComponent(tank);
|
||||||
if (!comp) { if (stats) stats.hullSource = '无组件'; return null; }
|
if (!comp) { if (stats) stats.hullSource = '无皮肤组件'; return null; }
|
||||||
if (comp.w14w_1 && comp.w14w_1.g17r_1) { if (stats) stats.hullSource = 'w14w_1'; return comp.w14w_1; } // 新 build
|
if (comp.g159_1 && comp.g159_1.g17r_1) { if (stats) stats.hullSource = 'g159_1'; return comp.g159_1; }
|
||||||
if (comp.t14l_1 && comp.t14l_1.g17r_1) { if (stats) stats.hullSource = 't14l_1'; return comp.t14l_1; } // 旧 build
|
|
||||||
if (comp.p14l_1 && comp.p14l_1.g17r_1) { if (stats) stats.hullSource = 'p14l_1'; return comp.p14l_1; } // 旧 build
|
|
||||||
if (stats) stats.hullSource = '有组件但无皮肤';
|
if (stats) stats.hullSource = '有组件但无皮肤';
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function GetTDtComponent(entity) {
|
// 炮塔 BP 根节点
|
||||||
var comp = FindComponentByField(entity, 'n11c_1');
|
function GetTurretNode(entity) {
|
||||||
if (comp) return comp;
|
var comp = GetSkinComponent(entity);
|
||||||
comp = FindComponentByField(entity, 'q112_1');
|
return (comp && comp.a17q_1) ? comp.a17q_1 : null;
|
||||||
return comp;
|
}
|
||||||
|
|
||||||
|
// 兼容两种集合:引擎列表类(e1/g1)与迭代器(t/u/v)
|
||||||
|
function ForEachInList(list, fn) {
|
||||||
|
if (!list) return;
|
||||||
|
try {
|
||||||
|
if (typeof list.e1 === 'function' && typeof list.g1 === 'function') {
|
||||||
|
var n = list.e1();
|
||||||
|
for (var i = 0; i < n; i++) fn(list.g1(i));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (typeof list.t === 'function') {
|
||||||
|
for (var it = list.t(); it.u();) fn(it.v());
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== 从GPU读取顶点位置数据(缓冲区[0]) =====
|
// ===== 从GPU读取顶点位置数据(缓冲区[0]) =====
|
||||||
@@ -372,14 +383,14 @@
|
|||||||
}
|
}
|
||||||
} catch(e) {}
|
} catch(e) {}
|
||||||
}
|
}
|
||||||
if (bpNode.p35_1 && typeof bpNode.p35_1.e1 === 'function') {
|
// 子节点:新版是 r35_1(zl 基类:this.r35_1 = new lo(),r3k 里递归子节点)
|
||||||
var childCount = bpNode.p35_1.e1();
|
// 旧版是 p35_1;新版 p35_1 已变成"世界矩阵",绝不能当子节点列表
|
||||||
for (var c = 0; c < childCount; c++) {
|
var Children = (bpNode.r35_1 && typeof bpNode.r35_1.e1 === 'function') ? bpNode.r35_1 :
|
||||||
try {
|
((bpNode.p35_1 && typeof bpNode.p35_1.e1 === 'function') ? bpNode.p35_1 : null);
|
||||||
var child = bpNode.p35_1.g1(c);
|
if (Children) {
|
||||||
if (child) CollectMeshNodes(child, nodes, depth + 1, group, stats);
|
ForEachInList(Children, function (child) {
|
||||||
} catch(e) {}
|
if (child) CollectMeshNodes(child, nodes, depth + 1, group, stats);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -389,25 +400,27 @@
|
|||||||
var skin = GetHullSkin(tank, stats);
|
var skin = GetHullSkin(tank, stats);
|
||||||
if (skin) {
|
if (skin) {
|
||||||
try {
|
try {
|
||||||
var partCount = skin.g17r_1.e1();
|
if (stats) stats.hullParts = (typeof skin.g17r_1.e1 === 'function') ? skin.g17r_1.e1() : -1;
|
||||||
if (stats) stats.hullParts = partCount;
|
ForEachInList(skin.g17r_1, function (part) {
|
||||||
for (var p = 0; p < partCount; p++) {
|
if (!part) return;
|
||||||
var part = skin.g17r_1.g1(p);
|
// 新版:part.j17r_1 是单个 BP 节点;旧版是节点列表
|
||||||
if (!part || !part.j17r_1) continue;
|
var j = part.j17r_1;
|
||||||
var nodeCount = part.j17r_1.e1();
|
if (!j) return;
|
||||||
for (var n = 0; n < nodeCount; n++) {
|
if (typeof j === 'object' && typeof j.e1 === 'function' && typeof j.g1 === 'function') {
|
||||||
var bpNode = part.j17r_1.g1(n);
|
ForEachInList(j, function (bp) {
|
||||||
if (!bpNode) continue;
|
if (bp) CollectMeshNodes(bp, nodes, 0, 'hull', stats ? stats.hull : null);
|
||||||
CollectMeshNodes(bpNode, nodes, 0, 'hull', stats ? stats.hull : null);
|
});
|
||||||
|
} else {
|
||||||
|
CollectMeshNodes(j, nodes, 0, 'hull', stats ? stats.hull : null);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
} catch(e) {}
|
} catch(e) {}
|
||||||
}
|
}
|
||||||
var tdt = GetTDtComponent(tank);
|
var turretNode = GetTurretNode(tank);
|
||||||
if (stats) stats.turretComp = !!tdt;
|
if (stats) stats.turretComp = !!turretNode;
|
||||||
if (tdt && tdt.n11c_1 && tdt.n11c_1.m17a_1) {
|
if (turretNode) {
|
||||||
if (stats) stats.turretRoot = true;
|
if (stats) stats.turretRoot = true;
|
||||||
try { CollectMeshNodes(tdt.n11c_1.m17a_1, nodes, 0, 'turret', stats ? stats.turret : null); } catch(e) {}
|
try { CollectMeshNodes(turretNode, nodes, 0, 'turret', stats ? stats.turret : null); } catch(e) {}
|
||||||
}
|
}
|
||||||
return nodes;
|
return nodes;
|
||||||
}
|
}
|
||||||
@@ -425,7 +438,13 @@
|
|||||||
var NodeMatrixScratch = new Float32Array(16);
|
var NodeMatrixScratch = new Float32Array(16);
|
||||||
|
|
||||||
function IsNodeValid(bpNode, pos, tankIsMoving, diagStats) {
|
function IsNodeValid(bpNode, pos, tankIsMoving, diagStats) {
|
||||||
var M = bpNode.n35_1;
|
// 世界矩阵:新版是 p35_1(zl 基类构造里 = hl(),s3k/t3k/u3k 读 p35_1[12..14])
|
||||||
|
// 旧版是 n35_1;新版 n35_1 已变成布尔标志
|
||||||
|
var M = bpNode.p35_1;
|
||||||
|
if (!M || typeof M.length !== 'number' || M.length < 16) {
|
||||||
|
var OldM = bpNode.n35_1;
|
||||||
|
M = (OldM && typeof OldM.length === 'number' && OldM.length >= 16) ? OldM : null;
|
||||||
|
}
|
||||||
if (!M) return null;
|
if (!M) return null;
|
||||||
if (diagStats) diagStats.totalNodes++;
|
if (diagStats) diagStats.totalNodes++;
|
||||||
|
|
||||||
|
|||||||
+14
-4
@@ -14,15 +14,25 @@
|
|||||||
var ZCt = null, m2Fn = null;
|
var ZCt = null, m2Fn = null;
|
||||||
|
|
||||||
// 加载队伍判断函数(从 module_87072 导出)
|
// 加载队伍判断函数(从 module_87072 导出)
|
||||||
// ZCt (mod.$_$.kd): 从坦克对象获取队伍ID
|
// 新旧差异(main.7cfa4058):
|
||||||
// m2 (mod.$_$.rk): 判断两个队伍ID是否相同且非中立 = t.equals(n) && !t.equals(E$())
|
// 取队伍 $_$.vd = WIt(t) → g$(HIt(), t).b135_1(坦克无队伍时返回中立 q$())
|
||||||
|
// 同队判定 $_$.dl = R7(a, b) → a.equals(b) && !a.equals(q$())
|
||||||
|
// ⚠ 旧键 $_$.kd / $_$.rk 在新版已指向无关的构造器类(CCt / FIn),用了会"敌我不分"
|
||||||
|
var TEAM_GET_KEYS = ['vd', 'kd'];
|
||||||
|
var TEAM_EQ_KEYS = ['dl', 'rk'];
|
||||||
function LoadTeamFunctions() {
|
function LoadTeamFunctions() {
|
||||||
if (ZCt && m2Fn) return { ZCt: ZCt, m2Fn: m2Fn };
|
if (ZCt && m2Fn) return { ZCt: ZCt, m2Fn: m2Fn };
|
||||||
try {
|
try {
|
||||||
var mod87072 = window.__wp_require__(87072);
|
var mod87072 = window.__wp_require__(87072);
|
||||||
if (mod87072 && mod87072.$_$) {
|
if (mod87072 && mod87072.$_$) {
|
||||||
ZCt = mod87072.$_$.kd;
|
for (var i = 0; i < TEAM_GET_KEYS.length && !ZCt; i++) {
|
||||||
m2Fn = mod87072.$_$.rk;
|
var G = mod87072.$_$[TEAM_GET_KEYS[i]];
|
||||||
|
if (typeof G === 'function') ZCt = G;
|
||||||
|
}
|
||||||
|
for (var j = 0; j < TEAM_EQ_KEYS.length && !m2Fn; j++) {
|
||||||
|
var E = mod87072.$_$[TEAM_EQ_KEYS[j]];
|
||||||
|
if (typeof E === 'function') m2Fn = E;
|
||||||
|
}
|
||||||
console.log('[公共库] 队伍判断函数已加载: ZCt=' + (typeof ZCt) + ', m2=' + (typeof m2Fn));
|
console.log('[公共库] 队伍判断函数已加载: ZCt=' + (typeof ZCt) + ', m2=' + (typeof m2Fn));
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
|||||||
Reference in new issue
Block a user