• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

PredatorCZ / RevilLib / 117

06 Nov 2023 06:12PM UTC coverage: 5.723% (-0.6%) from 6.277%
117

push

github

PredatorCZ
add mod xD3 x64

2 of 28 new or added lines in 3 files covered. (7.14%)

1200 existing lines in 3 files now uncovered.

351 of 6133 relevant lines covered (5.72%)

743.71 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

7.83
/src/mtf_mod/common.cpp
1
/*  Revil Format Library
2
    Copyright(C) 2017-2021 Lukas Cone
3

4
    This program is free software : you can redistribute it and / or modify
5
    it under the terms of the GNU General Public License as published by
6
    the Free Software Foundation, either version 3 of the License, or
7
    (at your option) any later version.
8

9
    This program is distributed in the hope that it will be useful,
10
    but WITHOUT ANY WARRANTY; without even the implied warranty of
11
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
12
    GNU General Public License for more details.
13

14
    You should have received a copy of the GNU General Public License
15
    along with this program.If not, see <https://www.gnu.org/licenses/>.
16
*/
17

18
#include "traits.hpp"
19
#include <set>
20
#include <span>
21

22
using namespace revil;
23

24
uni::TransformType MODBoneProxy::TMType() const { return uni::TMTYPE_MATRIX; }
×
25

26
size_t MODBoneProxy::Index() const { return index; }
×
27

28
std::string MODBoneProxy::Name() const { return ""; }
×
29

30
void MODBoneProxy::GetTM(es::Matrix44 &out) const {
×
31
  out = main.refPoses[index.id];
×
32
}
33

34
const uni::Bone *MODBoneProxy::Parent() const {
×
35
  return data.parentIndex == 0xff || data.parentIndex == 0xffff
×
36
             ? nullptr
×
37
             : &main.boneData.storage[data.parentIndex];
×
38
}
39

40
std::string MODImpl::Name() const { return ""; }
×
41

42
uni::SkeletonBonesConst MODImpl::Bones() const { return {&boneData, false}; }
×
43

44
size_t MODSkinProxy::NumNodes() const { return numRemaps; }
×
45
uni::TransformType MODSkinProxy::TMType() const { return uni::TMTYPE_MATRIX; }
×
46
void MODSkinProxy::GetTM(es::Matrix44 &out, size_t index) const {
×
47
  if (remaps) {
×
48
    out = poses[remaps[index]];
×
49
  } else {
50
    out = poses[index];
×
51
  }
52
}
53
size_t MODSkinProxy::NodeIndex(size_t index) const {
×
54
  return remaps ? remaps[index] : index;
×
55
}
56

57
inline size_t convertLod(es::Flags<uint8> vis) {
58
  LODIndex index;
59
  index.lod1 = vis[0];
×
60
  index.lod2 = vis[1];
×
61
  index.lod3 = vis[2];
×
62
  return index;
63
}
64

65
static const auto makeV1 = [](auto &self, auto &main, bool swap,
66
                              bool laterFormat) {
67
  auto &mat = main.materials.storage[self.materialIndex].main;
×
68
  using material_type = typename std::remove_reference<decltype(mat)>::type;
69
  auto useSkin = mat.vshData.template Get<typename material_type::SkinType>();
70
  bool skin8 = laterFormat ? useSkin == 4 : useSkin == 2;
×
71

72
  size_t offset = 0;
×
73
  size_t stride = self.buffer0Stride;
×
74
  MODPrimitiveProxyV1 retval;
75
  retval.lodIndex = convertLod(self.visibleLOD);
×
76
  retval.materialIndex = self.materialIndex;
×
77
  // retval.name = "group_" + std::to_string(self.unk);
78

79
  char *mainBuffer =
×
80
      main.buffer.data() + (self.vertexStart * self.buffer0Stride) +
×
81
      self.vertexStreamOffset + (self.indexValueOffset * self.buffer0Stride);
×
82
  auto curBuffer = mainBuffer;
×
83

84
  MODVertices vtArray;
85
  vtArray.numVertices = self.numVertices;
×
86

87
  auto newDesc = [&](uni::FormatDescr type, size_t size) {
×
88
    MODVertexDescriptor desc;
89
    desc.stride = stride;
×
90
    desc.offset = offset;
×
91
    desc.type = type;
×
92
    offset += size;
×
93
    desc.buffer = curBuffer + desc.offset;
×
94
    return desc;
95
  };
96

97
  auto makeBones = [&](size_t index) {
×
98
    MODVertexDescriptor boneIdx(
99
        newDesc({uni::FormatType::UINT, uni::DataType::R8G8B8A8}, 4));
100
    boneIdx.usage = uni::PrimitiveDescriptor::Usage_e::BoneIndices;
×
101
    boneIdx.index = index;
×
102
    vtArray.descs.storage.emplace_back(boneIdx);
×
103
  };
104

105
  auto makeWeights = [&](size_t index) {
×
106
    MODVertexDescriptor boneWt(
107
        newDesc({uni::FormatType::UNORM, uni::DataType::R8G8B8A8}, 4));
108
    boneWt.usage = uni::PrimitiveDescriptor::Usage_e::BoneWeights;
×
109
    boneWt.index = index;
×
110
    vtArray.descs.storage.emplace_back(boneWt);
×
111
  };
112

113
  auto makeNormals = [&](auto type) {
×
114
    MODVertexDescriptor norms(newDesc({uni::FormatType::NORM, type}, 4));
115

116
    if (laterFormat) {
×
117
      norms.type.compType = uni::DataType::R8G8B8A8;
×
118
      norms.type.outType = uni::FormatType::UNORM;
×
119
      norms.unpackType = uni::PrimitiveDescriptor::UnpackDataType_e::Madd;
×
120
      norms.unpackData.max = Vector4A16(-1.f);
×
121
      norms.unpackData.min = Vector4A16(2.f);
×
122
    }
123

124
    norms.usage = uni::PrimitiveDescriptor::Usage_e::Normal;
×
125
    vtArray.descs.storage.emplace_back(norms);
×
126

127
    if (!swap || laterFormat) {
×
128
      return;
129
    }
130

131
    auto normBuff = const_cast<char *>(norms.buffer);
132

133
    for (size_t i = 0; i < self.numVertices; i++) {
×
134
      FByteswapper(reinterpret_cast<uint32 &>(*normBuff));
×
135
      normBuff += self.buffer0Stride;
×
136
    }
137
  };
138

139
  auto makeTangents = [&] {
×
140
    MODVertexDescriptor tangs(
141
        newDesc({uni::FormatType::NORM, uni::DataType::R10G10B10A2}, 4));
142
    tangs.usage = uni::PrimitiveDescriptor::Usage_e::Tangent;
×
143
    vtArray.descs.storage.emplace_back(tangs);
×
144

145
    if (!swap) {
×
146
      return;
147
    }
148

149
    auto tangBuff = const_cast<char *>(tangs.buffer);
150

151
    for (size_t i = 0; i < self.numVertices; i++) {
×
152
      FByteswapper(reinterpret_cast<uint32 &>(*tangBuff));
×
153
      tangBuff += tangs.stride;
×
154
    }
155
  };
156

157
  auto makeUV = [&](size_t index) {
×
158
    MODVertexDescriptor uvset(
159
        newDesc({uni::FormatType::FLOAT, uni::DataType::R16G16}, 4));
160
    uvset.usage = uni::PrimitiveDescriptor::Usage_e::TextureCoordiante;
×
161
    uvset.index = index;
×
162
    vtArray.descs.storage.emplace_back(uvset);
×
163

164
    if (!swap) {
×
165
      return;
166
    }
167

168
    auto uvBuff = const_cast<char *>(uvset.buffer);
169

170
    for (size_t i = 0; i < self.numVertices; i++) {
×
171
      FByteswapper(reinterpret_cast<SVector2 &>(*uvBuff));
172
      uvBuff += uvset.stride;
×
173
    }
174
  };
175

176
  auto makeColor = [&](size_t index) {
×
177
    MODVertexDescriptor color(
178
        newDesc({uni::FormatType::UNORM, uni::DataType::R8G8B8A8}, 4));
179
    color.usage = uni::PrimitiveDescriptor::Usage_e::VertexColor;
×
180
    color.index = index;
×
181
    vtArray.descs.storage.emplace_back(color);
×
182

183
    if (!swap) {
×
184
      return;
185
    }
186

187
    auto colorBuff = const_cast<char *>(color.buffer);
188

189
    for (size_t i = 0; i < self.numVertices; i++) {
×
190
      auto &v = reinterpret_cast<uint32 &>(*colorBuff);
191
      FByteswapper(v);
×
192
      colorBuff += color.stride;
×
193
    }
194
  };
195

196
  if (useSkin) {
×
197
    MODVertexDescriptor pos(
198
        newDesc({laterFormat ? uni::FormatType::NORM : uni::FormatType::UNORM,
×
199
                 uni::DataType::R16G16B16A16},
200
                8));
201
    pos.usage = uni::PrimitiveDescriptor::Usage_e::Position;
×
202
    pos.unpackType = uni::PrimitiveDescriptor::UnpackDataType_e::Madd;
×
203
    pos.unpackData.max = main.bounds.bboxMin;
×
204
    pos.unpackData.min = main.bounds.bboxMax - main.bounds.bboxMin;
205

206
    vtArray.descs.storage.emplace_back(pos);
×
207

208
    if (swap) {
×
209
      auto posBuff = const_cast<char *>(pos.buffer);
210

211
      for (size_t i = 0; i < self.numVertices; i++) {
×
212
        FByteswapper(reinterpret_cast<USVector4 &>(*posBuff));
213
        posBuff += self.buffer0Stride;
×
214
      }
215
    }
216

217
    if (skin8) {
×
218
      makeBones(0);
×
219
      makeBones(1);
×
220
      makeWeights(0);
×
221
      makeWeights(1);
×
222
      makeNormals(uni::DataType::R10G10B10A2);
×
223
      makeUV(0);
×
224
    } else {
225
      makeBones(0);
×
226
      makeWeights(0);
×
227
      makeNormals(uni::DataType::R10G10B10A2);
×
228
      makeTangents();
×
229
      makeUV(0);
×
230
      makeUV(1);
×
231
    }
232
  } else {
233
    MODVertexDescriptor pos(
234
        newDesc({uni::FormatType::FLOAT, uni::DataType::R32G32B32}, 12));
235
    pos.usage = uni::PrimitiveDescriptor::Usage_e::Position;
×
236
    vtArray.descs.storage.emplace_back(pos);
×
237

238
    if (swap) {
×
239
      auto posBuff = const_cast<char *>(pos.buffer);
240

241
      for (size_t i = 0; i < self.numVertices; i++) {
×
242
        auto &vec = reinterpret_cast<Vector &>(*posBuff);
243
        FByteswapper(vec);
244
        posBuff += self.buffer0Stride;
×
245
      }
246
    }
247

248
    makeNormals(uni::DataType::R8G8B8A8);
×
249

250
    if (self.buffer1Stride != 8) {
×
251
      makeTangents();
×
252
      makeUV(0);
×
253
      makeUV(1);
×
254
      // makeColor(0); // null or swapped with tangent
255
    } else {
256
      offset += 4; // makeColor(0); // always null?
×
257
      makeUV(0);
×
258
      makeUV(1);
×
259
      makeTangents();
×
260
    }
261
  }
262

263
  if (skin8 && self.buffer1Stride != 8) {
×
264
    throw std::runtime_error("Expected secondary buffer of 8 bytes!");
×
265
  }
266

267
  if (!skin8 && useSkin && self.buffer1Stride) {
×
268
    throw std::runtime_error("Unexpected secondary buffer for skin!");
×
269
  }
270

271
  if (self.buffer1Stride) {
×
272
    retval.additionalBuffer = main.buffer.data() + main.vertexBufferSize;
×
273
    retval.additionalBuffer += self.vertexStream2Offset;
×
274
    offset = 0;
×
275
    stride = self.buffer1Stride;
×
276
    curBuffer = retval.additionalBuffer;
×
277

278
    if (skin8) {
×
279
      makeTangents();
×
280
      makeUV(1);
×
281
    } else {
282
      makeColor(0);
×
283

284
      if (offset < self.buffer1Stride) {
×
285
        makeColor(1);
×
286
      }
287
    }
288
  }
289

290
  uint16 *indexBuffer =
×
291
      reinterpret_cast<uint16 *>(&main.buffer[0] + main.vertexBufferSize +
×
292
                                 main.unkBufferSize + (self.indexStart * 2));
×
293
  retval.indexIndex = main.indices.Size();
×
294
  retval.vertexIndex = main.vertices.Size();
×
295

296
  MODIndices idArray;
297
  idArray.indexData = reinterpret_cast<const char *>(indexBuffer);
×
298
  idArray.numIndices = self.numIndices;
×
299

300
  for (size_t i = 0; i < self.numIndices; i++) {
×
301
    if (swap) {
×
302
      FByteswapper(indexBuffer[i]);
×
303
    }
304
    if (indexBuffer[i] != 0xffff) {
×
305
      indexBuffer[i] -= self.vertexStart;
×
306
    }
307
  }
308

309
  main.indices.storage.emplace_back(idArray);
×
310
  main.vertices.storage.emplace_back(std::move(vtArray));
×
311

312
  retval.indexType = uni::Primitive::IndexType_e::Strip;
×
313
  retval.name = std::to_string(self.unk);
×
314
  return retval;
×
315
};
316

317
MODPrimitiveProxyV1 MODMeshX70::ReflectBE(revil::MODImpl &main_) {
318
  auto &main = static_cast<MODInner<MODTraitsX70> &>(main_);
×
319
  return makeV1(*this, main, true, false);
320
}
321

×
322
MODPrimitiveProxyV1 MODMeshX99::ReflectLE(revil::MODImpl &main_) {
323
  auto &main = static_cast<MODInner<MODTraitsX99LE> &>(main_);
×
324
  auto retval = makeV1(*this, main, false, true);
×
325
  retval.skinIndex = skinInfo.boneRemapIndex;
326
  return retval;
×
327
}
×
328

329
MODPrimitiveProxyV1 MODMeshX99::ReflectBE(revil::MODImpl &main_) {
330
  auto &main = static_cast<MODInner<MODTraitsX99BE> &>(main_);
×
331
  auto retval = makeV1(*this, main, true, true);
×
332
  retval.skinIndex = skinInfo.boneRemapIndex;
×
333
  return retval;
×
334
}
335

336
MODVertices::MODVertices(std::initializer_list<MODVertexDescriptor> list) {
×
337
  descs.storage.insert(descs.storage.end(), list);
338
}
×
339

340
template <std::same_as<MODVertexDescriptor>... T>
×
341
MODVertices BuildVertices(T... items) {
×
342
  size_t offset = 0;
×
343
  static constexpr size_t fmtStrides[]{0,  128, 96, 64, 64, 48, 32, 32, 32,
×
344
                                       32, 32,  32, 24, 16, 16, 16, 16, 8};
×
345
  uint8 indices[0x10]{};
346

347
  auto NewDesc = [&](MODVertexDescriptor item) {
348
    item.offset = offset;
×
349
    item.index = indices[uint8(item.usage)]++;
350
    offset += fmtStrides[uint8(item.type.compType)] / 8;
351
    return item;
352
  };
353

354
  return MODVertices{NewDesc(items)...};
355
}
356

×
357
using F = uni::FormatType;
358
using D = uni::DataType;
359
using U = uni::PrimitiveDescriptor::Usage_e;
360
using V = MODVertexDescriptor;
361

362
static const MODVertexDescriptor VertexNormal = [] {
363
  V retVal{F::UNORM, D::R8G8B8A8, U::Normal};
364
  retVal.unpackType = uni::PrimitiveDescriptor::UnpackDataType_e::Madd;
×
365
  retVal.unpackData.min = Vector4A16{2};
366
  retVal.unpackData.max = Vector4A16{-1};
367
  return retVal;
368
}();
369

370
static const MODVertexDescriptor VertexTangent = [] {
371
  V retVal{F::UNORM, D::R8G8B8A8, U::Tangent};
372
  retVal.unpackType = uni::PrimitiveDescriptor::UnpackDataType_e::Madd;
373
  retVal.unpackData.min = Vector4A16{2};
374
  retVal.unpackData.max = Vector4A16{-1};
375
  return retVal;
376
}();
377

378
static const MODVertexDescriptor TexCoordPhone = [] {
379
  V retVal{F::UNORM, D::R16G16, U::TextureCoordiante};
380
  retVal.unpackType = uni::PrimitiveDescriptor::UnpackDataType_e::Mul;
381
  retVal.unpackData.min = Vector4A16{64};
382
  return retVal;
383
}();
384

385
// clang-format off
386

387
static const MODVertexDescriptor TexCoord{F::FLOAT, D::R16G16, U::TextureCoordiante};
388

389
static const MODVertexDescriptor VertexQPosition{F::NORM, D::R16G16B16, U::Position};
390

×
391
static const MODVertexDescriptor VertexPosition{F::FLOAT, D::R32G32B32, U::Position};
392

393
static const MODVertexDescriptor VertexBoneIndices{F::UINT, D::R8G8B8A8, U::BoneIndices};
394

395
static const MODVertexDescriptor VertexColor{F::UNORM, D::R8G8B8A8, U::VertexColor};
396

397
static const MODVertexDescriptor VertexNormalSigned{F::NORM, D::R8G8B8A8, U::Normal};
398

399
static const MODVertexDescriptor VertexTangentSigned{F::NORM, D::R8G8B8A8, U::Tangent};
400

401
std::map<uint32, MODVertices> formats{
402
    {
403
        0x64593023, // P3s_W1s_N4c_T4c_B4c_U2h_W2h_unk_U2h_unk
404
        BuildVertices(VertexQPosition,
405
                      V{F::NORM, D::R16, U::BoneWeights},
406
                      VertexNormal,
407
                      VertexTangent,
408
                      VertexBoneIndices,
×
409
                      TexCoord,
410
                      V{F::FLOAT, D::R16G16, U::BoneWeights},
411
                      V{F::UINT, D::R32, U::Undefined},
412
                      TexCoord,
413
                      V{F::UINT, D::R32, U::Undefined}),
414
    },
415
    {
416
        0x14d40020, // P3s_W1s_N4c_T4c_B4c_U2h_W2h
417
        BuildVertices(VertexQPosition,
418
                      V{F::NORM, D::R16, U::BoneWeights},
419
                      VertexNormal,
420
                      VertexTangent,
421
                      VertexBoneIndices,
422
                      TexCoord,
423
                      V{F::FLOAT, D::R16G16, U::BoneWeights}),
424
    },
425
    {
426
        0x14d40019, // P3s_W1s_N4c_T4c_B4c_U2h_W2h
427
        BuildVertices(VertexQPosition,
×
428
                      V{F::NORM, D::R16, U::BoneWeights},
429
                      VertexNormal,
430
                      VertexTangent,
431
                      VertexBoneIndices,
432
                      TexCoord,
433
                      V{F::FLOAT, D::R16G16, U::BoneWeights}),
434
    },
435
    {
436
        0x14d40021, // P3s_W1s_N4c_T4c_B4c_U2h_W2h
437
        BuildVertices(VertexQPosition,
438
                      V{F::NORM, D::R16, U::BoneWeights},
439
                      VertexNormalSigned,
440
                      VertexTangentSigned,
441
                      VertexBoneIndices,
442
                      TexCoord,
443
                      V{F::FLOAT, D::R16G16, U::BoneWeights}),
444
    },
445
    {
446
        0xbde5301a, // P3s_W1s_N4c_T4c_B4c_U2h_W2h
447
        BuildVertices(VertexQPosition,
×
448
                      V{F::NORM, D::R16, U::BoneWeights},
449
                      VertexNormal,
×
450
                      VertexTangent,
451
                      VertexBoneIndices,
452
                      TexCoord,
×
453
                      V{F::FLOAT, D::R16G16, U::BoneWeights}),
×
454
    },
×
455
    {
456
        0xd86ca01c, // P3s_W1s_N4c_T4c_B4c_U2h_W2h_VC4c
457
        BuildVertices(VertexQPosition,
×
458
                      V{F::NORM, D::R16, U::BoneWeights},
459
                      VertexNormal,
×
460
                      VertexTangent,
461
                      VertexBoneIndices,
462
                      TexCoord,
×
463
                      V{F::FLOAT, D::R16G16, U::BoneWeights},
464
                      VertexColor),
×
465
    },
466
    {
467
        0x77d87022, // P3s_W1s_N4c_T4c_B4c_U2h_W2h_VC4c
468
        BuildVertices(VertexQPosition,
×
469
                      V{F::NORM, D::R16, U::BoneWeights},
×
470
                      VertexNormal,
×
471
                      VertexTangent,
×
472
                      VertexBoneIndices,
×
473
                      TexCoord,
×
474
                      V{F::FLOAT, D::R16G16, U::BoneWeights},
×
475
                      VertexColor),
476
    },
×
477
    {
×
478
        0x77d87023, // P3s_W1s_N4c_T4c_B4c_U2h_W2h_VC4c
×
479
        BuildVertices(VertexQPosition,
×
480
                      V{F::NORM, D::R16, U::BoneWeights},
×
481
                      VertexNormalSigned,
×
482
                      VertexTangentSigned,
483
                      VertexBoneIndices,
484
                      TexCoord,
485
                      V{F::FLOAT, D::R16G16, U::BoneWeights},
486
                      VertexColor),
×
487
    },
×
488
    {
489
        0x207d6037, // P3f_N4c_U2h_VC4c
×
490
        BuildVertices(VertexPosition,
491
                      VertexNormal,
492
                      TexCoord,
×
493
                      VertexColor),
494
    },
495
    {
×
496
        0x207d6030, // P3f_N4c_U2h_VC4c
497
        BuildVertices(VertexPosition,
498
                      VertexNormal,
499
                      TexCoord,
×
500
                      VertexColor),
501
    },
×
502
    {
×
503
        0x207d6038, // P3f_N4c_U2h_VC4c
×
504
        BuildVertices(VertexPosition,
×
505
                      VertexNormalSigned,
506
                      TexCoord,
507
                      VertexColor),
×
508
    },
×
509
    {
×
510
        0x2f55c03d, // P3s_W1s_N4c_T4c_B4c_U2h_W2h_unk36c
×
511
        BuildVertices(VertexQPosition,
512
                      V{F::NORM, D::R16, U::BoneWeights},
513
                      VertexNormal,
514
                      VertexTangent,
×
515
                      VertexBoneIndices,
×
516
                      TexCoord,
517
                      V{F::FLOAT, D::R16G16, U::BoneWeights},
518
                      V{F::UINT, D::R32, U::Undefined},
×
519
                      V{F::UINT, D::R32G32B32A32, U::Undefined},
×
520
                      V{F::UINT, D::R32G32B32A32, U::Undefined}),
521
    },
522
    {
×
523
        0x49b4f029, // P3f_N4c_T4c_U2h_VC4c
×
524
        BuildVertices(VertexPosition,
×
525
                      VertexNormal,
×
526
                      VertexTangent,
×
527
                      TexCoord,
×
528
                      VertexColor),
529
    },
×
530
    {
×
531
        0x49b4f022, // P3f_N4c_T4c_U2h_VC4c
×
532
        BuildVertices(VertexPosition,
533
                      VertexNormal,
×
534
                      VertexTangent,
535
                      TexCoord,
×
536
                      VertexColor),
×
537
    },
538
    {
539
        0x49b4f02a, // P3f_N4c_T4c_U2h_VC4c
540
        BuildVertices(VertexPosition,
541
                      VertexNormalSigned,
×
542
                      VertexTangentSigned,
×
543
                      TexCoord,
×
544
                      VertexColor),
×
545
    },
×
546
    {
547
        0x5e7f202c, // P3f_N4c_T4c_U2h_U2h
548
        BuildVertices(VertexPosition,
×
549
                      VertexNormal,
×
550
                      VertexTangent,
551
                      TexCoord,
×
552
                      TexCoord),
×
553
    },
×
554
    {
555
        0x5e7f202d, // P3f_N4c_T4c_U2h_U2h
×
556
        BuildVertices(VertexPosition,
×
557
                      VertexNormalSigned,
558
                      VertexTangentSigned,
559
                      TexCoord,
560
                      TexCoord),
×
561
    },
×
562
    {
563
        0x747d1031, // P3f_N4c_T4c_U2h_U2h_U2h
×
564
        BuildVertices(VertexPosition,
×
565
                      VertexNormal,
×
566
                      VertexTangent,
567
                      TexCoord,
568
                      TexCoord,
569
                      TexCoord),
×
570
    },
571
    {
572
        0x75c3e025, // P3s_W1s_N4c_W4c_B8c_U2h_W2h_T4c_U2h
×
573
        BuildVertices(VertexQPosition,
574
                      V{F::NORM, D::R16, U::BoneWeights},
×
575
                      VertexNormal,
×
576
                      V{F::UNORM, D::R8G8B8A8, U::BoneWeights},
577
                      VertexBoneIndices,
×
578
                      VertexBoneIndices,
×
579
                      TexCoord,
580
                      V{F::FLOAT, D::R16G16, U::BoneWeights},
581
                      VertexTangent,
×
582
                      TexCoord),
×
583
    },
×
584
    {
×
585
        0x926fd02e, // P3f_N4c_T4c_U2h_U2h_VC4c
586
        BuildVertices(VertexPosition,
587
                      VertexNormal,
×
588
                      VertexTangent,
589
                      TexCoord,
×
590
                      TexCoord,
591
                      VertexColor),
×
592
    },
×
593
    {
×
594
        0xb86de02a, // P3f_N4c_T4c_U2h_U2h_VC4c
×
595
        BuildVertices(VertexPosition,
×
596
                      VertexNormal,
597
                      VertexTangent,
598
                      TexCoord,
599
                      TexCoord,
×
600
                      VertexColor),
601
    },
602
    {
603
        0xCBCF7027, // P3s_W1s_N4c_W4c_B8c_U2h_W2h_T4c_unk1i_U2h_unk1i
604
        BuildVertices(VertexQPosition,
605
                      V{F::NORM, D::R16, U::BoneWeights},
606
                      VertexNormal,
607
                      V{F::UNORM, D::R8G8B8A8, U::BoneWeights},
×
608
                      VertexBoneIndices,
609
                      VertexBoneIndices,
610
                      TexCoord,
611
                      V{F::FLOAT, D::R16G16, U::BoneWeights},
612
                      VertexTangent,
613
                      V{F::UINT, D::R32, U::Undefined},
614
                      TexCoord,
615
                      V{F::UINT, D::R32, U::Undefined}),
×
616
    },
617
    {
618
        0xbb424024, // P3s_W1s_N4c_W4c_B8c_U2h_W2h_T4c
619
        BuildVertices(VertexQPosition,
620
                      V{F::NORM, D::R16, U::BoneWeights},
621
                      VertexNormal,
622
                      V{F::UNORM, D::R8G8B8A8, U::BoneWeights},
623
                      VertexBoneIndices,
624
                      VertexBoneIndices,
625
                      TexCoord,
626
                      V{F::FLOAT, D::R16G16, U::BoneWeights},
627
                      VertexTangent),
628
    },
629
    {
630
        0x1273701e, // P3s_W1s_N4c_W4c_B8c_U2h_W2h_T4c
631
        BuildVertices(VertexQPosition,
632
                      V{F::NORM, D::R16, U::BoneWeights},
633
                      VertexNormal,
634
                      V{F::UNORM, D::R8G8B8A8, U::BoneWeights},
635
                      VertexBoneIndices,
636
                      VertexBoneIndices,
637
                      TexCoord,
638
                      V{F::FLOAT, D::R16G16, U::BoneWeights},
639
                      VertexTangent),
640
    },
641
    {
×
642
        0xbb42401d, // P3s_W1s_N4c_W4c_B8c_U2h_W2h_T4c
643
        BuildVertices(VertexQPosition,
644
                      V{F::NORM, D::R16, U::BoneWeights},
645
                      VertexNormal,
646
                      V{F::UNORM, D::R8G8B8A8, U::BoneWeights},
647
                      VertexBoneIndices,
648
                      VertexBoneIndices,
649
                      TexCoord,
650
                      V{F::FLOAT, D::R16G16, U::BoneWeights},
651
                      VertexTangent),
652
    },
653
    {
654
        0xbb424025, // P3s_W1s_N4c_W4c_B8c_U2h_W2h_T4c
655
        BuildVertices(VertexQPosition,
656
                      V{F::NORM, D::R16, U::BoneWeights},
657
                      VertexNormalSigned,
658
                      V{F::UNORM, D::R8G8B8A8, U::BoneWeights},
659
                      VertexBoneIndices,
×
660
                      VertexBoneIndices,
661
                      TexCoord,
662
                      V{F::FLOAT, D::R16G16, U::BoneWeights},
663
                      VertexTangentSigned),
664
    },
665
    {
666
        0xb392101f, // P3s_W1s_N4c_T4c_B2h_U2h_U2h_unk2i
667
        BuildVertices(VertexQPosition,
668
                      V{F::NORM, D::R16, U::BoneWeights},
669
                      VertexNormal,
670
                      VertexTangent,
671
                      V{F::FLOAT, D::R16G16, U::BoneIndices},
672
                      TexCoord,
673
                      TexCoord,
674
                      V{F::UINT, D::R32G32, U::Undefined}),
675
    },
676
    {
677
        0xda55a021, // P3s_W1s_N4c_T4c_B4c_U2h_W2s_U2h
678
        BuildVertices(VertexQPosition,
×
679
                      V{F::NORM, D::R16, U::BoneWeights},
680
                      VertexNormal,
681
                      VertexTangent,
682
                      VertexBoneIndices,
683
                      TexCoord,
684
                      V{F::FLOAT, D::R16G16, U::BoneWeights},
685
                      TexCoord),
686
    },
687
    {
688
        0xd9e801d, // P3s_W1s_N4c_T4c_U2h_B2h_U2h
689
        BuildVertices(VertexQPosition,
690
                      V{F::NORM, D::R16, U::BoneWeights},
691
                      VertexNormal,
692
                      VertexTangent,
693
                      TexCoord,
694
                      V{F::FLOAT, D::R16G16, U::BoneIndices},
695
                      TexCoord),
696
    },
697
    {
698
        0xc31f201c, // P3s_W1s_N4c_T4c_U2h_B2h
×
699
        BuildVertices(VertexQPosition,
700
                      V{F::NORM, D::R16, U::BoneWeights},
×
701
                      VertexNormal,
702
                      VertexTangent,
703
                      TexCoord,
×
704
                      V{F::FLOAT, D::R16G16, U::BoneIndices}),
×
705
    },
×
706
    {
707
        0x6a2e1016, // P3s_W1s_N4c_T4c_U2h_B2h
708
        BuildVertices(VertexQPosition,
×
709
                      V{F::NORM, D::R16, U::BoneWeights},
710
                      VertexNormal,
×
711
                      VertexTangent,
712
                      TexCoord,
713
                      V{F::FLOAT, D::R16G16, U::BoneIndices}),
×
714
    },
715
    {
×
716
        0xc31f2014, // P3s_W1s_N4c_T4c_U2h_B2h
717
        BuildVertices(VertexQPosition,
718
                      V{F::NORM, D::R16, U::BoneWeights},
719
                      VertexNormal,
×
720
                      VertexTangent,
×
721
                      TexCoord,
×
722
                      V{F::FLOAT, D::R16G16, U::BoneIndices}),
×
723
    },
×
724
    {
×
725
        0xc31f201d, // P3s_W1s_N4c_T4c_U2h_B2h
×
726
        BuildVertices(VertexQPosition,
727
                      V{F::NORM, D::R16, U::BoneWeights},
×
728
                      VertexNormalSigned,
×
729
                      VertexTangentSigned,
×
730
                      TexCoord,
×
731
                      V{F::FLOAT, D::R16G16, U::BoneIndices}),
×
732
    },
×
733
    {
734
        0xa013501e, // P3s_W1s_N4c_T4c_U2h_B2h_VC4c
735
        BuildVertices(VertexQPosition,
736
                      V{F::NORM, D::R16, U::BoneWeights},
737
                      VertexNormal,
×
738
                      VertexTangent,
×
739
                      TexCoord,
740
                      V{F::FLOAT, D::R16G16, U::BoneIndices},
×
741
                      VertexColor),
742
    },
743
    {
×
744
        0xa013501f, // P3s_W1s_N4c_T4c_U2h_B2h_VC4c
745
        BuildVertices(VertexQPosition,
746
                      V{F::NORM, D::R16, U::BoneWeights},
×
747
                      VertexNormalSigned,
748
                      VertexTangentSigned,
749
                      TexCoord,
750
                      V{F::FLOAT, D::R16G16, U::BoneIndices},
×
751
                      VertexColor),
752
    },
×
753
    {
×
754
        0xd877801b, // P3s_B1s_N4c_T4c_U2h_unk1i_U2h_unk1i
×
755
        BuildVertices(VertexQPosition,
×
756
                      V{F::INT, D::R16, U::BoneIndices},
757
                      VertexNormal,
758
                      VertexTangent,
×
759
                      TexCoord,
×
760
                      V{F::UINT, D::R32, U::Undefined},
×
761
                      TexCoord,
×
762
                      V{F::UINT, D::R32, U::Undefined}),
763
    },
764
    {
765
        0xcbf6c01a, // P3s_unk1s_T4c_N4c_U2h_VC4c
×
766
        BuildVertices(VertexQPosition,
×
767
                      V{F::UINT, D::R16, U::Undefined}, // bone?
768
                      VertexTangent,
769
                      VertexNormal,
×
770
                      TexCoord,
×
771
                      VertexColor),
772
    },
773
    {
×
774
        0xcbf6c01b, // P3s_unk1s_T4c_N4c_U2h_VC4c
×
775
        BuildVertices(VertexQPosition,
×
776
                      V{F::UINT, D::R16, U::Undefined}, // bone?
×
777
                      VertexTangentSigned,
×
778
                      VertexNormalSigned,
×
779
                      TexCoord,
780
                      VertexColor),
×
781
    },
×
782
    {
×
783
        0x37a4e035, // P3s_N4c_T4c_U2h_U2h_U2h_U2h
784
        BuildVertices(VertexPosition,
×
785
                      VertexNormal,
786
                      VertexTangent,
×
787
                      TexCoord,
×
788
                      TexCoord,
789
                      TexCoord,
790
                      TexCoord),
791
    },
792
    {
×
793
        0x12553032, // P3s_N4c_T4c_U2h_U2h_U2h
×
794
        BuildVertices(VertexPosition,
×
795
                      VertexNormal,
×
796
                      VertexTangent,
×
797
                      TexCoord,
798
                      TexCoord,
799
                      TexCoord),
×
800
    },
×
801
    {
802
        0xafa6302d, // P3f_N4c_T4c_U2h_U2h
×
803
        BuildVertices(VertexPosition,
×
804
                      VertexNormal,
×
805
                      VertexTangent,
806
                      TexCoord,
×
807
                      TexCoord),
×
808
    },
809
    {
810
        0xd8297028, // P3f_N4c_T4c_U2h
811
        BuildVertices(VertexPosition,
×
812
                      VertexNormal,
×
813
                      VertexTangent,
814
                      TexCoord),
×
815
    },
×
816
    {
×
817
        0xd8297021, // P3f_N4c_T4c_U2h
818
        BuildVertices(VertexPosition,
819
                      VertexNormal,
820
                      VertexTangent,
×
821
                      TexCoord),
822
    },
823
    {
×
824
        0xd8297029, // P3f_N4c_T4c_U2h
825
        BuildVertices(VertexPosition,
×
826
                      VertexNormalSigned,
×
827
                      VertexTangentSigned,
828
                      TexCoord),
×
829
    },
×
830
    {
831
        0x2082f03b, // P3f_N4c_U2h_U2h_U2h
832
        BuildVertices(VertexPosition,
×
833
                      VertexNormal,
×
834
                      TexCoord,
×
835
                      TexCoord,
×
836
                      TexCoord),
837
    },
838
    {
×
839
        0xc66fa03a, // P3f_N4c_U2h_U2h
840
        BuildVertices(VertexPosition,
×
841
                      VertexNormal,
842
                      TexCoord,
×
843
                      TexCoord),
×
844
    },
×
845
    {
×
846
        0xd1a47038, // P3f_N4c_U2h_U2h
×
847
        BuildVertices(VertexPosition,
848
                      VertexNormal,
849
                      TexCoord,
850
                      TexCoord),
×
851
    },
852
    {
853
        0xa7d7d036, // P3f_N4c_U2h
854
        BuildVertices(VertexPosition,
855
                      VertexNormal,
856
                      TexCoord),
857
    },
858
    {
×
859
        0xa7d7d02f, // P3f_N4c_U2h
860
        BuildVertices(VertexPosition,
861
                      VertexNormal,
862
                      TexCoord),
863
    },
864
    {
865
        0xa7d7d037, // P3f_N4c_U2h
866
        BuildVertices(VertexPosition,
×
867
                      VertexNormalSigned,
868
                      TexCoord),
869
    },
870
    {
871
        0xa14e003c, // P3f_N4c_U2h_U2h_VC4c
872
        BuildVertices(VertexPosition,
873
                      VertexNormal,
874
                      TexCoord,
875
                      TexCoord,
876
                      VertexColor),
877
    },
878
    {
879
        0x9399c033, // P3f_N4c_T4c_U2h_U2h_VC4c
880
        BuildVertices(VertexPosition,
881
                      VertexNormal,
882
                      VertexTangent,
883
                      TexCoord,
884
                      TexCoord,
885
                      VertexColor),
886
    },
887
    {
888
        0x4325a03e, // P3f_N4c_T4c_U2h_U2h_unk3h_unk1s_unki7
889
        BuildVertices(VertexPosition,
890
                      VertexNormal,
891
                      VertexTangent,
892
                      TexCoord,
×
893
                      TexCoord,
894
                      V{F::UINT, D::R32G32B32A32, U::Undefined},
895
                      V{F::UINT, D::R32G32B32A32, U::Undefined},
896
                      V{F::UINT, D::R32, U::Undefined}),
897
    },
898
    {
899
        0xb6681034, // P3f_N4c_T4c_U2h_U2h_VC4c_U2h
900
        BuildVertices(VertexPosition,
901
                      VertexNormal,
902
                      VertexTangent,
903
                      TexCoord,
904
                      TexCoord,
905
                      VertexColor,
906
                      TexCoord),
907
    },
908
    {
909
        0x63b6c02f, // P3f_N4c_T4c_U2h_U2h_U2h_unk1i
910
        BuildVertices(VertexPosition,
×
911
                      VertexNormal,
912
                      VertexTangent,
913
                      TexCoord,
914
                      TexCoord,
915
                      TexCoord,
916
                      V{F::UINT, D::R32, U::Undefined}),
917
    },
918
    {
919
        0xa8fab018, // P3f_1s_N4c_T4c_U2h
920
        BuildVertices(VertexQPosition,
921
                      V{F::INT, D::R16, U::BoneIndices},
922
                      VertexNormal,
923
                      VertexTangent,
924
                      TexCoord),
925
    },
926
    {
927
        0xa8fab010, // P3f_1s_N4c_T4c_U2h
928
        BuildVertices(VertexQPosition,
929
                      V{F::INT, D::R16, U::BoneIndices},
×
930
                      VertexNormal,
931
                      VertexTangent,
932
                      TexCoord),
933
    },
934
    {
935
        0xa8fab019, // P3f_1s_N4c_T4c_U2h
936
        BuildVertices(VertexQPosition,
937
                      V{F::INT, D::R16, U::BoneIndices},
938
                      VertexNormalSigned,
939
                      VertexTangentSigned,
940
                      TexCoord),
941
    },
942
    {
943
        0x1cb8011, // P3s_B1s_N4c_T4c_U2h
944
        BuildVertices(VertexQPosition,
945
                      V{F::INT, D::R16, U::BoneIndices},
946
                      VertexNormal,
947
                      VertexTangent,
948
                      TexCoord),
949
    },
×
950
    {
951
        0x1cb8011, // P3s_B1s_N4c_T4c_U2h_U2h
×
952
        BuildVertices(VertexQPosition,
953
                      V{F::INT, D::R16, U::BoneIndices},
954
                      VertexNormal,
×
955
                      VertexTangent,
×
956
                      TexCoord,
×
957
                      TexCoord),
958
    },
959
    {
×
960
        0xd84e3026, // P3s_W1s_N4c_W4c_B8c_U2h_W2h_T4c_VC4c
961
        BuildVertices(VertexQPosition,
×
962
                      V{F::NORM, D::R16, U::BoneWeights},
963
                      VertexNormal,
964
                      V{F::UNORM, D::R8G8B8A8, U::BoneWeights},
×
965
                      VertexBoneIndices,
966
                      VertexBoneIndices,
×
967
                      TexCoord,
968
                      V{F::FLOAT, D::R16G16, U::BoneWeights},
969
                      VertexTangent,
970
                      VertexColor),
×
971
    },
×
972
    {
×
973
        0xd84e3027, // P3s_W1s_N4c_W4c_B8c_U2h_W2h_T4c_VC4c
×
974
        BuildVertices(VertexQPosition,
×
975
                      V{F::NORM, D::R16, U::BoneWeights},
×
976
                      VertexNormalSigned,
×
977
                      V{F::UNORM, D::R8G8B8A8, U::BoneWeights},
978
                      VertexBoneIndices,
×
979
                      VertexBoneIndices,
×
980
                      TexCoord,
×
981
                      V{F::FLOAT, D::R16G16, U::BoneWeights},
×
982
                      VertexTangentSigned,
×
983
                      VertexColor),
×
984
    },
985
    {
986
        0xa8fab009, // P3s_unk1s_N4c_B4c_U2s_T4c
987
        BuildVertices(VertexQPosition,
988
                      V{F::UINT, D::R16, U::Undefined},
×
989
                      VertexNormalSigned,
×
990
                      VertexBoneIndices,
991
                      TexCoordPhone,
×
992
                      VertexTangentSigned),
993
    },
994
    {
×
995
        0xAE62600B, // P3s_unk1s_N4c_T4c_B4c_W4c_U2h
996
        BuildVertices(VertexQPosition,
997
                      V{F::UINT, D::R16, U::Undefined},
×
998
                      VertexNormalSigned,
999
                      VertexTangentSigned,
1000
                      VertexBoneIndices,
1001
                      V{F::UNORM, D::R8G8B8A8, U::BoneWeights},
×
1002
                      TexCoordPhone),
1003
    },
×
NEW
1004
    {
×
NEW
1005
        0x667B1019, // P3s_unk1s_N4c_VC4c_U2h_T4c
×
NEW
1006
        BuildVertices(VertexQPosition,
×
1007
                      V{F::UINT, D::R16, U::Undefined},
1008
                      VertexNormal,
NEW
1009
                      VertexColor,
×
NEW
1010
                      TexCoord,
×
NEW
1011
                      VertexTangent),
×
NEW
1012
    },
×
1013
};
1014

1015
// clang-format on
UNCOV
1016

×
UNCOV
1017
static const std::set<uint32> edgeModels{
×
1018
    0xdb7da014,
1019
    // P3s_unk1s_B4c_W4c_N4c
NEW
1020
    0x0CB68015,
×
NEW
1021
    // P3s_B1s_N4c
×
1022
    0xB0983013,
1023
    // P3s_unk1s_B8c_W8c_N4c
NEW
1024
    0xA320C016,
×
1025
};
×
1026

×
1027
static const auto makeV2 = [](auto &self, revil::MODImpl &main, bool swap,
×
UNCOV
1028
                              auto &&fd) {
×
UNCOV
1029
  MODPrimitiveProxy retval;
×
1030
  uint8 visibleLOD = self.data0.template Get<MODMeshXC5::VisibleLOD>();
1031
  retval.lodIndex =
×
1032
      convertLod(reinterpret_cast<es::Flags<uint8> &>(visibleLOD));
×
UNCOV
1033
  retval.materialIndex = self.data0.template Get<MODMeshXC5::MaterialIndex>();
×
1034
  const MODMeshXC5::PrimitiveType_e primitiveType = MODMeshXC5::PrimitiveType_e(
NEW
1035
      self.data1.template Get<MODMeshXC5::PrimitiveType>());
×
1036

NEW
1037
  switch (primitiveType) {
×
NEW
1038
  case MODMeshXC5::PrimitiveType_e::Triangles:
×
1039
    retval.indexType = uni::Primitive::IndexType_e::Triangle;
1040
    break;
1041

1042
  case MODMeshXC5::PrimitiveType_e::Strips:
NEW
1043
    retval.indexType = uni::Primitive::IndexType_e::Strip;
×
NEW
1044
    break;
×
NEW
1045

×
NEW
1046
  default:
×
NEW
1047
    retval.indexType = uni::Primitive::IndexType_e::None;
×
1048
    break;
1049
  }
1050
  retval.indexIndex = main.indices.Size();
×
1051
  retval.vertexIndex = main.vertices.Size();
×
1052
  retval.name = std::to_string(self.meshIndex) + ":" +
UNCOV
1053
                std::to_string(self.data0.template Get<MODMeshXC5::GroupID>());
×
1054
  const size_t vertexStride =
×
1055
      self.data1.template Get<MODMeshXC5::VertexBufferStride>();
×
1056

1057
  char *mainBuffer = main.buffer.data() + (self.vertexStart * vertexStride) +
×
1058
                     self.vertexStreamOffset +
×
1059
                     (self.indexValueOffset * vertexStride);
1060

1061
  auto foundFormat = formats.find(self.vertexFormat);
1062

×
1063
  if (!es::IsEnd(formats, foundFormat)) {
×
1064
    MODVertices tmpl = foundFormat->second;
1065
    tmpl.numVertices = self.numVertices;
×
UNCOV
1066
    for (auto &d : tmpl.descs.storage) {
×
1067
      d.buffer = mainBuffer + d.offset;
×
1068
      d.stride = vertexStride;
1069
      fd(d);
UNCOV
1070
    }
×
1071
    main.vertices.storage.emplace_back(std::move(tmpl));
UNCOV
1072
  } else {
×
1073
    main.vertices.storage.emplace_back();
1074

NEW
1075
    /*if (!edgeModels.contains(self.vertexFormat)) {
×
1076
      throw std::runtime_error("Unregistered vertex format: " +
NEW
1077
                               std::to_string(self.vertexFormat));
×
NEW
1078
    }*/
×
1079
  }
×
1080

1081
  uint16 *indexBuffer = reinterpret_cast<uint16 *>(
UNCOV
1082
      &main.buffer[0] + main.vertexBufferSize + (self.indexStart * 2));
×
1083

1084
  MODIndices idArray;
×
UNCOV
1085
  idArray.indexData = reinterpret_cast<const char *>(indexBuffer);
×
1086
  idArray.numIndices = self.numIndices;
×
1087

1088
  if (swap) {
1089
    for (size_t i = 0; i < self.numIndices; i++) {
65✔
1090
      if (indexBuffer[i] != 0xffff) {
65✔
1091
        FByteswapper(indexBuffer[i]);
65✔
1092
        indexBuffer[i] -= self.vertexStart;
1093
      }
1094
    }
65✔
1095
  } else {
65✔
1096
    for (size_t i = 0; i < self.numIndices; i++) {
1097
      if (indexBuffer[i] != 0xffff) {
1098
        indexBuffer[i] -= self.vertexStart;
65✔
1099
      }
1100
    }
481✔
1101
  }
416✔
1102

416✔
1103
  main.indices.storage.emplace_back(idArray);
416✔
1104

416✔
1105
  return retval;
1106
};
1107

546✔
1108
static const auto swapBuffers = [](MODVertexDescriptor &d, size_t numVertices) {
130✔
1109
  char *curBuffer = d.buffer;
3✔
1110

3✔
1111
  switch (d.type.compType) {
1112
  case uni::DataType::R16: {
1113
    for (size_t v = 0; v < numVertices; v++, curBuffer += d.stride) {
3✔
1114
      FByteswapper(*reinterpret_cast<uint16 *>(curBuffer));
1115
    }
3✔
1116
    break;
1117
  }
1118

1119
  case uni::DataType::R16G16: {
1120
    for (size_t v = 0; v < numVertices; v++, curBuffer += d.stride) {
1121
      FByteswapper(*reinterpret_cast<USVector2 *>(curBuffer));
1122
    }
15✔
1123
    break;
6✔
1124
  }
4✔
1125

4✔
1126
  case uni::DataType::R16G16B16: {
1127
    for (size_t v = 0; v < numVertices; v++, curBuffer += d.stride) {
1128
      FByteswapper(*reinterpret_cast<USVector *>(curBuffer));
4✔
1129
    }
1130
    break;
4✔
1131
  }
1132

1133
  case uni::DataType::R32G32B32: {
1134
    for (size_t v = 0; v < numVertices; v++, curBuffer += d.stride) {
1135
      FByteswapper(*reinterpret_cast<Vector *>(curBuffer));
1136
    }
1137
    break;
44✔
1138
  }
8✔
1139

1✔
1140
  default:
1✔
1141
    break;
1142
  }
1143
};
1✔
1144

1145
MODPrimitiveProxy MODMeshXD2::ReflectLE(revil::MODImpl &main_) {
1✔
1146
  auto &main = static_cast<MODInner<MODTraitsXD3> &>(main_);
1147
  return makeV2(*this, main, false, [&](MODVertexDescriptor &d) {
1148
    if (d.usage == uni::PrimitiveDescriptor::Usage_e::BoneIndices &&
1149
        skinBoneBegin) {
1150
      d.unpackType = uni::PrimitiveDescriptor::UnpackDataType_e::Add;
1151
      d.unpackData.min = Vector4A16(skinBoneBegin);
1152
    }
14✔
1153
  });
2✔
1154
}
14✔
1155

14✔
1156
MODPrimitiveProxy MODMeshXD2::ReflectBE(revil::MODImpl &main_) {
1157
  auto &main = static_cast<MODInner<MODTraitsXD2> &>(main_);
1158
  return makeV2(*this, main, true, [&](MODVertexDescriptor &d) {
14✔
1159
    if (d.usage == uni::PrimitiveDescriptor::Usage_e::BoneIndices &&
1160
        skinBoneBegin < main.bones.size()) {
14✔
1161
      d.unpackType = uni::PrimitiveDescriptor::UnpackDataType_e::Add;
1162
      d.unpackData.min = Vector4A16(skinBoneBegin);
1163
    }
1164

1165
    swapBuffers(d, numVertices);
1166
  });
1167
}
112✔
1168

28✔
1169
MODPrimitiveProxy MODMeshXD3PS4::ReflectLE(revil::MODImpl &main_) {
12✔
1170
  auto &main = static_cast<MODInner<MODTraitsXD2> &>(main_);
12✔
1171
  return makeV2(*this, main, false, [&](MODVertexDescriptor &d) {
1172
    if (d.usage == uni::PrimitiveDescriptor::Usage_e::BoneIndices &&
1173
        skinBoneBegin) {
12✔
1174
      d.unpackType = uni::PrimitiveDescriptor::UnpackDataType_e::Add;
1175
      d.unpackData.min = Vector4A16(skinBoneBegin);
12✔
1176
    } else if (d.usage == uni::PrimitiveDescriptor::Usage_e::Normal) {
1177
      d.type = VertexNormalSigned.type;
1178
      d.unpackType = uni::PrimitiveDescriptor::UnpackDataType_e::None;
1179
    } else if (d.usage == uni::PrimitiveDescriptor::Usage_e::Tangent) {
1180
      d.type = VertexTangentSigned.type;
1181
      d.unpackType = uni::PrimitiveDescriptor::UnpackDataType_e::None;
1182
    }
84✔
1183
  });
24✔
1184
}
8✔
1185

8✔
1186
MODPrimitiveProxy MODMeshXD3::ReflectLE(revil::MODImpl &main_) {
1187
  auto &main = static_cast<MODInner<MODTraitsXD2> &>(main_);
1188
  return makeV2(*this, main, false, [&](MODVertexDescriptor &d) {
8✔
1189
    if (d.usage == uni::PrimitiveDescriptor::Usage_e::BoneIndices &&
1190
        skinBoneBegin) {
8✔
1191
      d.unpackType = uni::PrimitiveDescriptor::UnpackDataType_e::Add;
1192
      d.unpackData.min = Vector4A16(skinBoneBegin);
1193
    }
1194
  });
1195
}
1196

1197
MODPrimitiveProxy MODMeshXC5::ReflectLE(revil::MODImpl &main_) {
48✔
1198
  auto &main = static_cast<MODInner<MODTraitsXC5> &>(main_);
16✔
1199
  return makeV2(*this, main, false, [&](MODVertexDescriptor &) {});
7✔
1200
}
7✔
1201

1202
MODPrimitiveProxy MODMeshX06::ReflectLE(revil::MODImpl &main_) {
1203
  auto &main = static_cast<MODInner<MODTraitsXD3> &>(main_);
7✔
1204
  auto retval = makeV2(*this, main, false, [&](MODVertexDescriptor &) {});
1205
  retval.skinIndex = skinBoneBegin;
7✔
1206

1207
  /*auto idxArray = main.Indices()->At(retval.indexIndex);
1208
  std::span<const uint16> indices(
1209
      reinterpret_cast<const uint16 *>(idxArray->RawIndexBuffer()), numIndices);
1210

1211
  bool removeTS = true;
1212

70✔
1213
  for (auto d : vtArray.descs) {
14✔
1214
    switch (d->Usage()) {
11✔
1215
    case uni::PrimitiveDescriptor::Usage_e::Normal: {
11✔
1216
      uni::FormatCodec::fvec sampled;
1217
      d->Codec().Sample(sampled, d->RawBuffer(), numVertices, d->Stride());
1218
      for (auto i : indices) {
11✔
1219
        if (i == 0xffff) {
1220
          continue;
11✔
1221
        }
1222

1223
        auto s = sampled.at(i);
1224
        if (s.Length() > 0.5f) {
1225
          removeTS = false;
1226
          //break;
1227
        } else {
99✔
1228
          printf("%i ", i);
22✔
1229
        }
5✔
1230
      }
5✔
1231

1232
      break;
1233
    }
5✔
1234

1235
    default:
5✔
1236
      break;
1237
    }
1238
  }
1239

1240
  if (removeTS) {
1241
    std::remove_if(vtArray.descs.storage.begin(), vtArray.descs.storage.end(),
1242
                   [](MODVertexDescriptor &d) {
60✔
1243
                     return d.usage == MODVertexDescriptor::Usage_e::Normal;
10✔
1244
                   });
1245
    std::remove_if(vtArray.descs.storage.begin(), vtArray.descs.storage.end(),
1246
                   [](MODVertexDescriptor &d) {
1247
                     return d.usage == MODVertexDescriptor::Usage_e::Tangent;
1248
                   });
1249
  }*/
1250

1251
  return retval;
1252
}
1253

1254
std::string MODPrimitiveProxy::Name() const { return name; }
1255
size_t MODPrimitiveProxy::SkinIndex() const { return skinIndex; }
1256
int64 MODPrimitiveProxy::LODIndex() const { return lodIndex; }
1257
size_t MODPrimitiveProxy::MaterialIndex() const { return materialIndex; }
1258
uni::Primitive::IndexType_e MODPrimitiveProxy::IndexType() const {
1259
  return indexType;
1260
}
1261
size_t MODPrimitiveProxy::VertexArrayIndex(size_t) const { return vertexIndex; }
1262
size_t MODPrimitiveProxy::IndexArrayIndex() const { return indexIndex; }
1263
size_t MODPrimitiveProxy::NumVertexArrays() const { return 1; }
1264

1265
MOD::MOD() {}
1266
MOD::MOD(MOD &&) = default;
1267
MOD::~MOD() = default;
1268

1269
namespace revil {
1270
template <>
1271
ES_EXPORT uni::Element<const uni::Skeleton>
1272
MOD::As<uni::Element<const uni::Skeleton>>() const {
1273
  return {static_cast<const uni::Skeleton *>(this->pi.get()), false};
1274
}
1275

1276
template <>
1277
ES_EXPORT uni::Element<const uni::Model>
1278
MOD::As<uni::Element<const uni::Model>>() const {
1279
  return {static_cast<const uni::Model *>(this->pi.get()), false};
1280
}
1281
} // namespace revil
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc