mirror of https://github.com/AxioDL/metaforce.git
Several GameCube cooking fixes
This commit is contained in:
parent
ecaf7f313f
commit
d5e471bac3
|
@ -22,29 +22,33 @@ void ReadBabeDeadLightToBlender(hecl::blender::PyOutStream& os,
|
||||||
return;
|
return;
|
||||||
case BabeDeadLight::LightType::Directional:
|
case BabeDeadLight::LightType::Directional:
|
||||||
os.format("lamp = bpy.data.lamps.new('LAMP_%01u_%03u', 'SUN')\n"
|
os.format("lamp = bpy.data.lamps.new('LAMP_%01u_%03u', 'SUN')\n"
|
||||||
|
"lamp.color = (%f,%f,%f)\n"
|
||||||
"lamp_obj = bpy.data.objects.new(lamp.name, lamp)\n"
|
"lamp_obj = bpy.data.objects.new(lamp.name, lamp)\n"
|
||||||
"lamp_obj.rotation_mode = 'QUATERNION'\n"
|
"lamp_obj.rotation_mode = 'QUATERNION'\n"
|
||||||
"lamp_obj.rotation_quaternion = Vector((0,0,-1)).rotation_difference(Vector((%f,%f,%f)))\n"
|
"lamp_obj.rotation_quaternion = Vector((0,0,-1)).rotation_difference(Vector((%f,%f,%f)))\n"
|
||||||
"lamp.shadow_method = '%s'\n"
|
"lamp.shadow_method = '%s'\n"
|
||||||
"\n", s, l,
|
"\n", s, l, light.color.vec[0], light.color.vec[1], light.color.vec[2],
|
||||||
light.direction.vec[0], light.direction.vec[1], light.direction.vec[2],
|
light.direction.vec[0], light.direction.vec[1], light.direction.vec[2],
|
||||||
light.castShadows ? "RAY_SHADOW" : "NOSHADOW");
|
light.castShadows ? "RAY_SHADOW" : "NOSHADOW");
|
||||||
return;
|
return;
|
||||||
case BabeDeadLight::LightType::Custom:
|
case BabeDeadLight::LightType::Custom:
|
||||||
os.format("lamp = bpy.data.lamps.new('LAMP_%01u_%03u', 'POINT')\n"
|
os.format("lamp = bpy.data.lamps.new('LAMP_%01u_%03u', 'POINT')\n"
|
||||||
|
"lamp.color = (%f,%f,%f)\n"
|
||||||
"lamp_obj = bpy.data.objects.new(lamp.name, lamp)\n"
|
"lamp_obj = bpy.data.objects.new(lamp.name, lamp)\n"
|
||||||
"lamp.shadow_method = '%s'\n"
|
"lamp.shadow_method = '%s'\n"
|
||||||
"\n", s, l, light.castShadows ? "RAY_SHADOW" : "NOSHADOW");
|
"\n", s, l, light.color.vec[0], light.color.vec[1], light.color.vec[2],
|
||||||
|
light.castShadows ? "RAY_SHADOW" : "NOSHADOW");
|
||||||
break;
|
break;
|
||||||
case BabeDeadLight::LightType::Spot:
|
case BabeDeadLight::LightType::Spot:
|
||||||
case BabeDeadLight::LightType::Spot2:
|
case BabeDeadLight::LightType::Spot2:
|
||||||
os.format("lamp = bpy.data.lamps.new('LAMP_%01u_%03u', 'SPOT')\n"
|
os.format("lamp = bpy.data.lamps.new('LAMP_%01u_%03u', 'SPOT')\n"
|
||||||
|
"lamp.color = (%f,%f,%f)\n"
|
||||||
"lamp.spot_size = %.6g\n"
|
"lamp.spot_size = %.6g\n"
|
||||||
"lamp_obj = bpy.data.objects.new(lamp.name, lamp)\n"
|
"lamp_obj = bpy.data.objects.new(lamp.name, lamp)\n"
|
||||||
"lamp_obj.rotation_mode = 'QUATERNION'\n"
|
"lamp_obj.rotation_mode = 'QUATERNION'\n"
|
||||||
"lamp_obj.rotation_quaternion = Vector((0,0,-1)).rotation_difference(Vector((%f,%f,%f)))\n"
|
"lamp_obj.rotation_quaternion = Vector((0,0,-1)).rotation_difference(Vector((%f,%f,%f)))\n"
|
||||||
"lamp.shadow_method = '%s'\n"
|
"lamp.shadow_method = '%s'\n"
|
||||||
"\n", s, l,
|
"\n", s, l, light.color.vec[0], light.color.vec[1], light.color.vec[2],
|
||||||
zeus::degToRad(light.spotCutoff),
|
zeus::degToRad(light.spotCutoff),
|
||||||
light.direction.vec[0], light.direction.vec[1], light.direction.vec[2],
|
light.direction.vec[0], light.direction.vec[1], light.direction.vec[2],
|
||||||
light.castShadows ? "RAY_SHADOW" : "NOSHADOW");
|
light.castShadows ? "RAY_SHADOW" : "NOSHADOW");
|
||||||
|
@ -127,18 +131,18 @@ void WriteBabeDeadLightFromBlender(BabeDeadLight& lightOut, const hecl::blender:
|
||||||
lightIn.linear > lightIn.quadratic)
|
lightIn.linear > lightIn.quadratic)
|
||||||
{
|
{
|
||||||
lightOut.falloff = BabeDeadLight::Falloff::Linear;
|
lightOut.falloff = BabeDeadLight::Falloff::Linear;
|
||||||
lightOut.q = 1.f / (lightIn.linear / 250.f);
|
lightOut.q = 250.f / lightIn.linear;
|
||||||
}
|
}
|
||||||
else if (lightIn.quadratic > lightIn.constant &&
|
else if (lightIn.quadratic > lightIn.constant &&
|
||||||
lightIn.quadratic > lightIn.linear)
|
lightIn.quadratic > lightIn.linear)
|
||||||
{
|
{
|
||||||
lightOut.falloff = BabeDeadLight::Falloff::Quadratic;
|
lightOut.falloff = BabeDeadLight::Falloff::Quadratic;
|
||||||
lightOut.q = 1.f / (lightIn.quadratic / 25000.f);
|
lightOut.q = 25000.f / lightIn.quadratic;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lightOut.falloff = BabeDeadLight::Falloff::Constant;
|
lightOut.falloff = BabeDeadLight::Falloff::Constant;
|
||||||
lightOut.q = 1.f / (lightIn.constant / 2.f);
|
lightOut.q = 2.f / lightIn.constant;
|
||||||
}
|
}
|
||||||
|
|
||||||
lightOut.color = lightIn.color;
|
lightOut.color = lightIn.color;
|
||||||
|
|
|
@ -1243,8 +1243,6 @@ bool WriteCMDL(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPath
|
||||||
hecl::Frontend::Frontend FE;
|
hecl::Frontend::Frontend FE;
|
||||||
for (const std::vector<Material>& mset : mesh.materialSets)
|
for (const std::vector<Material>& mset : mesh.materialSets)
|
||||||
{
|
{
|
||||||
std::unordered_map<uint64_t, int> uniqueMatMap;
|
|
||||||
|
|
||||||
matSets.emplace_back();
|
matSets.emplace_back();
|
||||||
MaterialSet& targetMSet = matSets.back();
|
MaterialSet& targetMSet = matSets.back();
|
||||||
std::vector<hecl::ProjectPath> texPaths;
|
std::vector<hecl::ProjectPath> texPaths;
|
||||||
|
@ -1262,7 +1260,7 @@ bool WriteCMDL(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPath
|
||||||
|
|
||||||
targetMSet.materials.emplace_back(matGX, mat.iprops, mat.texs, texPaths,
|
targetMSet.materials.emplace_back(matGX, mat.iprops, mat.texs, texPaths,
|
||||||
mesh.colorLayerCount, mesh.uvLayerCount,
|
mesh.colorLayerCount, mesh.uvLayerCount,
|
||||||
false, false, uniqueMatMap);
|
false, false);
|
||||||
|
|
||||||
targetMSet.materials.back().binarySize(endOff);
|
targetMSet.materials.back().binarySize(endOff);
|
||||||
targetMSet.head.addMaterialEndOff(endOff);
|
targetMSet.head.addMaterialEndOff(endOff);
|
||||||
|
@ -1353,7 +1351,7 @@ bool WriteCMDL(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPath
|
||||||
size_t vertSz = matSets.at(0).materials.at(surf.materialIdx).getVAFlags().vertDLSize();
|
size_t vertSz = matSets.at(0).materials.at(surf.materialIdx).getVAFlags().vertDLSize();
|
||||||
if (surf.verts.size() > 65536)
|
if (surf.verts.size() > 65536)
|
||||||
LogDNACommon.report(logvisor::Fatal, "GX DisplayList overflow");
|
LogDNACommon.report(logvisor::Fatal, "GX DisplayList overflow");
|
||||||
size_t secSz = 68 + surf.verts.size() * vertSz;
|
size_t secSz = 67 + surf.verts.size() * vertSz;
|
||||||
secSz32 = ROUND_UP_32(secSz);
|
secSz32 = ROUND_UP_32(secSz);
|
||||||
if (secSz32 == 0)
|
if (secSz32 == 0)
|
||||||
secSz32 = 32;
|
secSz32 = 32;
|
||||||
|
@ -1445,7 +1443,7 @@ bool WriteCMDL(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPath
|
||||||
SurfaceHeader header;
|
SurfaceHeader header;
|
||||||
header.centroid = surf.centroid;
|
header.centroid = surf.centroid;
|
||||||
header.matIdx = surf.materialIdx;
|
header.matIdx = surf.materialIdx;
|
||||||
header.dlSize = ROUND_UP_32(4 + surf.verts.size() * vertSz);
|
header.dlSize = ROUND_UP_32(3 + surf.verts.size() * vertSz);
|
||||||
header.reflectionNormal = surf.reflectionNormal;
|
header.reflectionNormal = surf.reflectionNormal;
|
||||||
header.write(writer);
|
header.write(writer);
|
||||||
|
|
||||||
|
@ -1478,8 +1476,6 @@ bool WriteCMDL(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPath
|
||||||
WriteDLVal(writer, vaFlags.tex6(), vert.iUv[6]);
|
WriteDLVal(writer, vaFlags.tex6(), vert.iUv[6]);
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.writeUByte(0);
|
|
||||||
|
|
||||||
writer.fill(atUint8(0), *padIt);
|
writer.fill(atUint8(0), *padIt);
|
||||||
++padIt;
|
++padIt;
|
||||||
}
|
}
|
||||||
|
@ -1696,7 +1692,6 @@ bool WriteMREASecs(std::vector<std::vector<uint8_t>>& secsOut, const hecl::Proje
|
||||||
MaterialSet matSet;
|
MaterialSet matSet;
|
||||||
{
|
{
|
||||||
MaterialPool matPool;
|
MaterialPool matPool;
|
||||||
std::unordered_map<uint64_t, int> uniqueMatMap;
|
|
||||||
|
|
||||||
size_t surfCount = 0;
|
size_t surfCount = 0;
|
||||||
for (const Mesh& mesh : meshes)
|
for (const Mesh& mesh : meshes)
|
||||||
|
@ -1748,7 +1743,7 @@ bool WriteMREASecs(std::vector<std::vector<uint8_t>>& secsOut, const hecl::Proje
|
||||||
|
|
||||||
matSet.materials.emplace_back(matGX, mat.iprops, mat.texs, texPaths,
|
matSet.materials.emplace_back(matGX, mat.iprops, mat.texs, texPaths,
|
||||||
mesh.colorLayerCount, mesh.uvLayerCount,
|
mesh.colorLayerCount, mesh.uvLayerCount,
|
||||||
lm, false, uniqueMatMap);
|
lm, false);
|
||||||
|
|
||||||
matSet.materials.back().binarySize(endOff);
|
matSet.materials.back().binarySize(endOff);
|
||||||
matSet.head.addMaterialEndOff(endOff);
|
matSet.head.addMaterialEndOff(endOff);
|
||||||
|
@ -1914,7 +1909,7 @@ bool WriteMREASecs(std::vector<std::vector<uint8_t>>& secsOut, const hecl::Proje
|
||||||
SurfaceHeader header;
|
SurfaceHeader header;
|
||||||
header.centroid = meshXf * zeus::CVector3f(surf.centroid);
|
header.centroid = meshXf * zeus::CVector3f(surf.centroid);
|
||||||
header.matIdx = matIdx;
|
header.matIdx = matIdx;
|
||||||
header.dlSize = ROUND_UP_32(4 + surf.verts.size() * vertSz);
|
header.dlSize = ROUND_UP_32(3 + surf.verts.size() * vertSz);
|
||||||
header.reflectionNormal = (meshXf.basis * zeus::CVector3f(surf.reflectionNormal)).normalized();
|
header.reflectionNormal = (meshXf.basis * zeus::CVector3f(surf.reflectionNormal)).normalized();
|
||||||
header.aabbSz = 24;
|
header.aabbSz = 24;
|
||||||
zeus::CAABox aabb(zeus::CVector3f(surf.aabbMin), zeus::CVector3f(surf.aabbMax));
|
zeus::CAABox aabb(zeus::CVector3f(surf.aabbMin), zeus::CVector3f(surf.aabbMax));
|
||||||
|
@ -1924,7 +1919,7 @@ bool WriteMREASecs(std::vector<std::vector<uint8_t>>& secsOut, const hecl::Proje
|
||||||
|
|
||||||
size_t secSz = 0;
|
size_t secSz = 0;
|
||||||
header.binarySize(secSz);
|
header.binarySize(secSz);
|
||||||
secSz += 4 + surf.verts.size() * vertSz;
|
secSz += 3 + surf.verts.size() * vertSz;
|
||||||
secSz = ROUND_UP_32(secSz);
|
secSz = ROUND_UP_32(secSz);
|
||||||
secsOut.emplace_back(secSz, 0);
|
secsOut.emplace_back(secSz, 0);
|
||||||
athena::io::MemoryWriter w(secsOut.back().data(), secsOut.back().size());
|
athena::io::MemoryWriter w(secsOut.back().data(), secsOut.back().size());
|
||||||
|
@ -1958,8 +1953,6 @@ bool WriteMREASecs(std::vector<std::vector<uint8_t>>& secsOut, const hecl::Proje
|
||||||
WriteDLVal(w, vaFlags.tex5(), vert.iUv[5]);
|
WriteDLVal(w, vaFlags.tex5(), vert.iUv[5]);
|
||||||
WriteDLVal(w, vaFlags.tex6(), vert.iUv[6]);
|
WriteDLVal(w, vaFlags.tex6(), vert.iUv[6]);
|
||||||
}
|
}
|
||||||
|
|
||||||
w.writeUByte(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -603,7 +603,7 @@ static uint8_t* EncodePaletteSPLT(png_structp png, png_infop info, int numEntrie
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t format = 0; /* Default IA8 */
|
uint32_t format = 2; /* Default RGB5A3 */
|
||||||
for (int e=0 ; e<pngNumEntries ; ++e)
|
for (int e=0 ; e<pngNumEntries ; ++e)
|
||||||
{
|
{
|
||||||
png_sPLT_entryp ent = &cEntries[e];
|
png_sPLT_entryp ent = &cEntries[e];
|
||||||
|
@ -672,7 +672,7 @@ static uint8_t* EncodePaletteSPLT(png_structp png, png_infop info, int numEntrie
|
||||||
for (int e=0 ; e<numEntries ; ++e)
|
for (int e=0 ; e<numEntries ; ++e)
|
||||||
{
|
{
|
||||||
uint16_t texel = 0;
|
uint16_t texel = 0;
|
||||||
if (cEntries[e].alpha == 0xff)
|
if (cEntries && cEntries[e].alpha == 0xff)
|
||||||
{
|
{
|
||||||
texel |= 0x8000;
|
texel |= 0x8000;
|
||||||
if (e < pngNumEntries)
|
if (e < pngNumEntries)
|
||||||
|
@ -1321,7 +1321,7 @@ bool TXTR::Cook(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPat
|
||||||
{
|
{
|
||||||
Log.report(logvisor::Error, "image must be 4x4 or larger");
|
Log.report(logvisor::Error, "image must be 4x4 or larger");
|
||||||
fclose(inf);
|
fclose(inf);
|
||||||
png_destroy_read_struct(&pngRead, nullptr, nullptr);
|
png_destroy_read_struct(&pngRead, &info, nullptr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1163,10 +1163,24 @@ bool ANCS::Cook(const hecl::ProjectPath& outPath,
|
||||||
hecl::SystemStringConv chSysName(ch.name);
|
hecl::SystemStringConv chSysName(ch.name);
|
||||||
ch.cskr = inPath.ensureAuxInfo(hecl::SystemString(chSysName.sys_str()) + _S(".CSKR"));
|
ch.cskr = inPath.ensureAuxInfo(hecl::SystemString(chSysName.sys_str()) + _S(".CSKR"));
|
||||||
|
|
||||||
|
int subtypeIdx = 0;
|
||||||
|
ch.animAABBs.clear();
|
||||||
for (const DNAANCS::Actor::Subtype& sub : actor.subtypes)
|
for (const DNAANCS::Actor::Subtype& sub : actor.subtypes)
|
||||||
{
|
{
|
||||||
if (!sub.name.compare(ch.name))
|
if (!sub.name.compare(ch.name))
|
||||||
{
|
{
|
||||||
|
/* Add subtype AABBs */
|
||||||
|
ch.animAABBs.reserve(actor.actions.size());
|
||||||
|
for (const DNAANCS::Action& act : actor.actions)
|
||||||
|
{
|
||||||
|
const auto& sourceAABB = act.subtypeAABBs[subtypeIdx];
|
||||||
|
ch.animAABBs.emplace_back();
|
||||||
|
auto& destAABB = ch.animAABBs.back();
|
||||||
|
destAABB.name = act.name;
|
||||||
|
destAABB.aabb[0] = sourceAABB.first.val;
|
||||||
|
destAABB.aabb[1] = sourceAABB.second.val;
|
||||||
|
}
|
||||||
|
|
||||||
if (sub.armature >= 0)
|
if (sub.armature >= 0)
|
||||||
{
|
{
|
||||||
const DNAANCS::Armature& arm = actor.armatures[sub.armature];
|
const DNAANCS::Armature& arm = actor.armatures[sub.armature];
|
||||||
|
@ -1180,11 +1194,17 @@ bool ANCS::Cook(const hecl::ProjectPath& outPath,
|
||||||
ch.cskrOverlay = inPath.ensureAuxInfo(hecl::SystemString(chSysName.sys_str()) + _S('.') +
|
ch.cskrOverlay = inPath.ensureAuxInfo(hecl::SystemString(chSysName.sys_str()) + _S('.') +
|
||||||
overlaySys.c_str() + _S(".CSKR"));
|
overlaySys.c_str() + _S(".CSKR"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
++subtypeIdx;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
std::sort(ch.animAABBs.begin(), ch.animAABBs.end(),
|
||||||
|
[](const ANCS::CharacterSet::CharacterInfo::ActionAABB& a,
|
||||||
|
const ANCS::CharacterSet::CharacterInfo::ActionAABB& b)
|
||||||
|
{ return a.name < b.name; });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set Animation Resource IDs */
|
/* Set Animation Resource IDs */
|
||||||
|
|
|
@ -932,11 +932,10 @@ MaterialSet::Material::Material(const hecl::Backend::GX& gx,
|
||||||
int colorCount,
|
int colorCount,
|
||||||
int uvCount,
|
int uvCount,
|
||||||
bool lightmapUVs,
|
bool lightmapUVs,
|
||||||
bool matrixSkinning,
|
bool matrixSkinning)
|
||||||
std::unordered_map<uint64_t, int>& uniqueMap)
|
|
||||||
{
|
{
|
||||||
XXH64_state_t xxHash;
|
XXH32_state_t xxHash;
|
||||||
XXH64_reset(&xxHash, 0);
|
XXH32_reset(&xxHash, 0);
|
||||||
|
|
||||||
if (gx.m_kcolorCount)
|
if (gx.m_kcolorCount)
|
||||||
{
|
{
|
||||||
|
@ -979,6 +978,7 @@ MaterialSet::Material::Material(const hecl::Backend::GX& gx,
|
||||||
flags.setLightmapUVArray(lightmapUVs);
|
flags.setLightmapUVArray(lightmapUVs);
|
||||||
|
|
||||||
atUint16 texFlags = 0;
|
atUint16 texFlags = 0;
|
||||||
|
atUint16 tcgFlags = 0;
|
||||||
tevStageTexInfo.reserve(gx.m_tevCount);
|
tevStageTexInfo.reserve(gx.m_tevCount);
|
||||||
textureIdxs.reserve(gx.m_tevCount);
|
textureIdxs.reserve(gx.m_tevCount);
|
||||||
for (unsigned i=0 ; i<gx.m_tevCount ; ++i)
|
for (unsigned i=0 ; i<gx.m_tevCount ; ++i)
|
||||||
|
@ -987,7 +987,12 @@ MaterialSet::Material::Material(const hecl::Backend::GX& gx,
|
||||||
tevStageTexInfo.emplace_back();
|
tevStageTexInfo.emplace_back();
|
||||||
TEVStageTexInfo& texInfo = tevStageTexInfo.back();
|
TEVStageTexInfo& texInfo = tevStageTexInfo.back();
|
||||||
if (stage.m_texGenIdx != -1)
|
if (stage.m_texGenIdx != -1)
|
||||||
|
{
|
||||||
texInfo.tcgSlot = stage.m_texGenIdx;
|
texInfo.tcgSlot = stage.m_texGenIdx;
|
||||||
|
const hecl::Backend::GX::TexCoordGen& tcg = gx.m_tcgs[stage.m_texGenIdx];
|
||||||
|
if (tcg.m_src >= hecl::Backend::GX::TG_TEX0 && tcg.m_src <= hecl::Backend::GX::TG_TEX6)
|
||||||
|
tcgFlags |= 1 << (tcg.m_src - hecl::Backend::GX::TG_TEX0);
|
||||||
|
}
|
||||||
if (stage.m_texMapIdx != -1)
|
if (stage.m_texMapIdx != -1)
|
||||||
{
|
{
|
||||||
texInfo.texSlot = textureIdxs.size();
|
texInfo.texSlot = textureIdxs.size();
|
||||||
|
@ -1013,7 +1018,7 @@ MaterialSet::Material::Material(const hecl::Backend::GX& gx,
|
||||||
}
|
}
|
||||||
flags.setTextureSlots(texFlags);
|
flags.setTextureSlots(texFlags);
|
||||||
|
|
||||||
XXH64_update(&xxHash, &flags.flags, sizeof(flags.flags));
|
XXH32_update(&xxHash, &flags.flags, sizeof(flags.flags));
|
||||||
|
|
||||||
vaFlags.setPosition(GX::INDEX16);
|
vaFlags.setPosition(GX::INDEX16);
|
||||||
vaFlags.setNormal(GX::INDEX16);
|
vaFlags.setNormal(GX::INDEX16);
|
||||||
|
@ -1023,61 +1028,61 @@ MaterialSet::Material::Material(const hecl::Backend::GX& gx,
|
||||||
if (1 < colorCount)
|
if (1 < colorCount)
|
||||||
vaFlags.setColor1(GX::INDEX16);
|
vaFlags.setColor1(GX::INDEX16);
|
||||||
|
|
||||||
if (0 < uvCount)
|
if (tcgFlags & (1 << 0))
|
||||||
vaFlags.setTex0(GX::INDEX16);
|
vaFlags.setTex0(GX::INDEX16);
|
||||||
if (1 < uvCount)
|
if (tcgFlags & (1 << 1))
|
||||||
vaFlags.setTex1(GX::INDEX16);
|
vaFlags.setTex1(GX::INDEX16);
|
||||||
if (2 < uvCount)
|
if (tcgFlags & (1 << 2))
|
||||||
vaFlags.setTex2(GX::INDEX16);
|
vaFlags.setTex2(GX::INDEX16);
|
||||||
if (3 < uvCount)
|
if (tcgFlags & (1 << 3))
|
||||||
vaFlags.setTex3(GX::INDEX16);
|
vaFlags.setTex3(GX::INDEX16);
|
||||||
if (4 < uvCount)
|
if (tcgFlags & (1 << 4))
|
||||||
vaFlags.setTex4(GX::INDEX16);
|
vaFlags.setTex4(GX::INDEX16);
|
||||||
if (5 < uvCount)
|
if (tcgFlags & (1 << 5))
|
||||||
vaFlags.setTex5(GX::INDEX16);
|
vaFlags.setTex5(GX::INDEX16);
|
||||||
if (6 < uvCount)
|
if (tcgFlags & (1 << 6))
|
||||||
vaFlags.setTex6(GX::INDEX16);
|
vaFlags.setTex6(GX::INDEX16);
|
||||||
|
|
||||||
if (matrixSkinning)
|
if (matrixSkinning)
|
||||||
{
|
{
|
||||||
vaFlags.setPnMatIdx(GX::DIRECT);
|
vaFlags.setPnMatIdx(GX::DIRECT);
|
||||||
if (0 < uvCount)
|
if (tcgFlags & (1 << 0))
|
||||||
vaFlags.setTex0MatIdx(GX::DIRECT);
|
vaFlags.setTex0MatIdx(GX::DIRECT);
|
||||||
if (1 < uvCount)
|
if (tcgFlags & (1 << 1))
|
||||||
vaFlags.setTex1MatIdx(GX::DIRECT);
|
vaFlags.setTex1MatIdx(GX::DIRECT);
|
||||||
if (2 < uvCount)
|
if (tcgFlags & (1 << 2))
|
||||||
vaFlags.setTex2MatIdx(GX::DIRECT);
|
vaFlags.setTex2MatIdx(GX::DIRECT);
|
||||||
if (3 < uvCount)
|
if (tcgFlags & (1 << 3))
|
||||||
vaFlags.setTex3MatIdx(GX::DIRECT);
|
vaFlags.setTex3MatIdx(GX::DIRECT);
|
||||||
if (4 < uvCount)
|
if (tcgFlags & (1 << 4))
|
||||||
vaFlags.setTex4MatIdx(GX::DIRECT);
|
vaFlags.setTex4MatIdx(GX::DIRECT);
|
||||||
if (5 < uvCount)
|
if (tcgFlags & (1 << 5))
|
||||||
vaFlags.setTex5MatIdx(GX::DIRECT);
|
vaFlags.setTex5MatIdx(GX::DIRECT);
|
||||||
if (6 < uvCount)
|
if (tcgFlags & (1 << 6))
|
||||||
vaFlags.setTex6MatIdx(GX::DIRECT);
|
vaFlags.setTex6MatIdx(GX::DIRECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
XXH64_update(&xxHash, &vaFlags.vaFlags, sizeof(vaFlags.vaFlags));
|
XXH32_update(&xxHash, &vaFlags.vaFlags, sizeof(vaFlags.vaFlags));
|
||||||
|
|
||||||
XXH64_update(&xxHash, &gx.m_kcolorCount, sizeof(gx.m_kcolorCount));
|
XXH32_update(&xxHash, &gx.m_kcolorCount, sizeof(gx.m_kcolorCount));
|
||||||
for (unsigned i=0 ; i<gx.m_kcolorCount ; ++i)
|
for (unsigned i=0 ; i<gx.m_kcolorCount ; ++i)
|
||||||
{
|
{
|
||||||
konstColors.emplace_back(gx.m_kcolors[i]);
|
konstColors.emplace_back(gx.m_kcolors[i]);
|
||||||
XXH64_update(&xxHash, &gx.m_kcolors[i].num, sizeof(gx.m_kcolors[i].num));
|
XXH32_update(&xxHash, &gx.m_kcolors[i].num, sizeof(gx.m_kcolors[i].num));
|
||||||
}
|
}
|
||||||
|
|
||||||
blendDstFac = BlendFactor(gx.m_blendDst);
|
blendDstFac = BlendFactor(gx.m_blendDst);
|
||||||
XXH64_update(&xxHash, &gx.m_blendDst, sizeof(gx.m_blendDst));
|
XXH32_update(&xxHash, &gx.m_blendDst, sizeof(gx.m_blendDst));
|
||||||
blendSrcFac = BlendFactor(gx.m_blendSrc);
|
blendSrcFac = BlendFactor(gx.m_blendSrc);
|
||||||
XXH64_update(&xxHash, &gx.m_blendSrc, sizeof(gx.m_blendSrc));
|
XXH32_update(&xxHash, &gx.m_blendSrc, sizeof(gx.m_blendSrc));
|
||||||
if (flags.samusReflectionIndirectTexture())
|
if (flags.samusReflectionIndirectTexture())
|
||||||
{
|
{
|
||||||
indTexSlot.push_back(textureIdxs.size());
|
indTexSlot.push_back(textureIdxs.size());
|
||||||
XXH64_update(&xxHash, &indTexSlot.back(), sizeof(indTexSlot.back()));
|
XXH32_update(&xxHash, &indTexSlot.back(), sizeof(indTexSlot.back()));
|
||||||
}
|
}
|
||||||
|
|
||||||
colorChannelCount = 1;
|
colorChannelCount = 1;
|
||||||
XXH64_update(&xxHash, &colorChannelCount, sizeof(colorChannelCount));
|
XXH32_update(&xxHash, &colorChannelCount, sizeof(colorChannelCount));
|
||||||
colorChannels.emplace_back();
|
colorChannels.emplace_back();
|
||||||
ColorChannel& ch = colorChannels.back();
|
ColorChannel& ch = colorChannels.back();
|
||||||
for (unsigned i=0 ; i<gx.m_tevCount ; ++i)
|
for (unsigned i=0 ; i<gx.m_tevCount ; ++i)
|
||||||
|
@ -1090,7 +1095,7 @@ MaterialSet::Material::Material(const hecl::Backend::GX& gx,
|
||||||
{
|
{
|
||||||
ch.setLighting(true);
|
ch.setLighting(true);
|
||||||
uint8_t one = 1;
|
uint8_t one = 1;
|
||||||
XXH64_update(&xxHash, &one, sizeof(one));
|
XXH32_update(&xxHash, &one, sizeof(one));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (ch.lighting())
|
if (ch.lighting())
|
||||||
|
@ -1100,7 +1105,7 @@ MaterialSet::Material::Material(const hecl::Backend::GX& gx,
|
||||||
ch.setAttenuationFn(GX::AF_SPOT);
|
ch.setAttenuationFn(GX::AF_SPOT);
|
||||||
|
|
||||||
tevStageCount = gx.m_tevCount;
|
tevStageCount = gx.m_tevCount;
|
||||||
XXH64_update(&xxHash, &tevStageCount, sizeof(tevStageCount));
|
XXH32_update(&xxHash, &tevStageCount, sizeof(tevStageCount));
|
||||||
tevStages.reserve(gx.m_tevCount);
|
tevStages.reserve(gx.m_tevCount);
|
||||||
for (unsigned i=0 ; i<gx.m_tevCount ; ++i)
|
for (unsigned i=0 ; i<gx.m_tevCount ; ++i)
|
||||||
{
|
{
|
||||||
|
@ -1129,17 +1134,27 @@ MaterialSet::Material::Material(const hecl::Backend::GX& gx,
|
||||||
target.setKColorIn(stage.m_kColor);
|
target.setKColorIn(stage.m_kColor);
|
||||||
target.setKAlphaIn(stage.m_kAlpha);
|
target.setKAlphaIn(stage.m_kAlpha);
|
||||||
|
|
||||||
XXH64_update(&xxHash, &target.ciFlags, sizeof(target.ciFlags));
|
target.setRASIn(GX::GX_COLOR_NULL);
|
||||||
XXH64_update(&xxHash, &target.aiFlags, sizeof(target.aiFlags));
|
for (int c=0 ; c<4 ; ++c)
|
||||||
XXH64_update(&xxHash, &target.ccFlags, sizeof(target.ccFlags));
|
if (stage.m_color[c] == hecl::Backend::GX::CC_RASC ||
|
||||||
XXH64_update(&xxHash, &target.acFlags, sizeof(target.acFlags));
|
stage.m_color[c] == hecl::Backend::GX::CC_RASA ||
|
||||||
XXH64_update(&xxHash, &target.kaInput, sizeof(target.kaInput));
|
stage.m_alpha[c] == hecl::Backend::GX::CA_RASA)
|
||||||
XXH64_update(&xxHash, &target.kcInput, sizeof(target.kcInput));
|
{
|
||||||
XXH64_update(&xxHash, &target.rascInput, sizeof(target.rascInput));
|
target.setRASIn(GX::GX_COLOR0A0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
XXH32_update(&xxHash, &target.ciFlags, sizeof(target.ciFlags));
|
||||||
|
XXH32_update(&xxHash, &target.aiFlags, sizeof(target.aiFlags));
|
||||||
|
XXH32_update(&xxHash, &target.ccFlags, sizeof(target.ccFlags));
|
||||||
|
XXH32_update(&xxHash, &target.acFlags, sizeof(target.acFlags));
|
||||||
|
XXH32_update(&xxHash, &target.kaInput, sizeof(target.kaInput));
|
||||||
|
XXH32_update(&xxHash, &target.kcInput, sizeof(target.kcInput));
|
||||||
|
XXH32_update(&xxHash, &target.rascInput, sizeof(target.rascInput));
|
||||||
}
|
}
|
||||||
|
|
||||||
tcgCount = gx.m_tcgCount;
|
tcgCount = gx.m_tcgCount;
|
||||||
XXH64_update(&xxHash, &tcgCount, sizeof(tcgCount));
|
XXH32_update(&xxHash, &tcgCount, sizeof(tcgCount));
|
||||||
for (unsigned i=0 ; i<gx.m_tcgCount ; ++i)
|
for (unsigned i=0 ; i<gx.m_tcgCount ; ++i)
|
||||||
{
|
{
|
||||||
const hecl::Backend::GX::TexCoordGen& tcg = gx.m_tcgs[i];
|
const hecl::Backend::GX::TexCoordGen& tcg = gx.m_tcgs[i];
|
||||||
|
@ -1151,7 +1166,7 @@ MaterialSet::Material::Material(const hecl::Backend::GX& gx,
|
||||||
target.setNormalize(tcg.m_norm);
|
target.setNormalize(tcg.m_norm);
|
||||||
target.setPostMtx(tcg.m_pmtx);
|
target.setPostMtx(tcg.m_pmtx);
|
||||||
|
|
||||||
XXH64_update(&xxHash, &target.flags, sizeof(target.flags));
|
XXH32_update(&xxHash, &target.flags, sizeof(target.flags));
|
||||||
}
|
}
|
||||||
|
|
||||||
uvAnimsSize = 4;
|
uvAnimsSize = 4;
|
||||||
|
@ -1169,8 +1184,9 @@ MaterialSet::Material::Material(const hecl::Backend::GX& gx,
|
||||||
found = true;
|
found = true;
|
||||||
++uvAnimsCount;
|
++uvAnimsCount;
|
||||||
uvAnims.emplace_back(tcg.m_gameFunction, tcg.m_gameArgs);
|
uvAnims.emplace_back(tcg.m_gameFunction, tcg.m_gameArgs);
|
||||||
XXH64_update(&xxHash, tcg.m_gameFunction.data(), sizeof(tcg.m_gameFunction.size()));
|
XXH32_update(&xxHash, tcg.m_gameFunction.data(), sizeof(tcg.m_gameFunction.size()));
|
||||||
XXH64_update(&xxHash, &tcg.m_gameArgs, sizeof(tcg.m_gameArgs));
|
for (const atVec4f& arg : tcg.m_gameArgs)
|
||||||
|
XXH32_update(&xxHash, &arg, sizeof(arg));
|
||||||
size_t tmpUvAnimsSize = uvAnimsSize;
|
size_t tmpUvAnimsSize = uvAnimsSize;
|
||||||
uvAnims.back().binarySize(tmpUvAnimsSize);
|
uvAnims.back().binarySize(tmpUvAnimsSize);
|
||||||
uvAnimsSize = tmpUvAnimsSize;
|
uvAnimsSize = tmpUvAnimsSize;
|
||||||
|
@ -1181,14 +1197,10 @@ MaterialSet::Material::Material(const hecl::Backend::GX& gx,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
XXH64_update(&xxHash, &uvAnimsSize, sizeof(uvAnimsSize));
|
XXH32_update(&xxHash, &uvAnimsSize, sizeof(uvAnimsSize));
|
||||||
XXH64_update(&xxHash, &uvAnimsCount, sizeof(uvAnimsCount));
|
XXH32_update(&xxHash, &uvAnimsCount, sizeof(uvAnimsCount));
|
||||||
|
|
||||||
uint64_t hash = XXH64_digest(&xxHash);
|
uniqueIdx = XXH32_digest(&xxHash);
|
||||||
auto hashSearch = uniqueMap.find(hash);
|
|
||||||
if (hashSearch == uniqueMap.end())
|
|
||||||
hashSearch = uniqueMap.insert(std::make_pair(hash, uniqueMap.size())).first;
|
|
||||||
uniqueIdx = hashSearch->second;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HMDLMaterialSet::Material::Material(hecl::Frontend::Frontend& FE,
|
HMDLMaterialSet::Material::Material(hecl::Frontend::Frontend& FE,
|
||||||
|
|
|
@ -217,6 +217,9 @@ struct MaterialSet : BigDNA
|
||||||
void setKColorIn(GX::TevKColorSel val) {kcInput = val;}
|
void setKColorIn(GX::TevKColorSel val) {kcInput = val;}
|
||||||
GX::TevKAlphaSel kAlphaIn() const {return GX::TevKAlphaSel(kaInput);}
|
GX::TevKAlphaSel kAlphaIn() const {return GX::TevKAlphaSel(kaInput);}
|
||||||
void setKAlphaIn(GX::TevKAlphaSel val) {kaInput = val;}
|
void setKAlphaIn(GX::TevKAlphaSel val) {kaInput = val;}
|
||||||
|
|
||||||
|
GX::ChannelID rasIn() const {return GX::ChannelID(rascInput);}
|
||||||
|
void setRASIn(GX::ChannelID id) {rascInput = id;}
|
||||||
};
|
};
|
||||||
Vector<TEVStage, AT_DNA_COUNT(tevStageCount)> tevStages;
|
Vector<TEVStage, AT_DNA_COUNT(tevStageCount)> tevStages;
|
||||||
struct TEVStageTexInfo : BigDNA
|
struct TEVStageTexInfo : BigDNA
|
||||||
|
@ -290,8 +293,7 @@ struct MaterialSet : BigDNA
|
||||||
int colorCount,
|
int colorCount,
|
||||||
int uvCount,
|
int uvCount,
|
||||||
bool lightmapUVs,
|
bool lightmapUVs,
|
||||||
bool matrixSkinning,
|
bool matrixSkinning);
|
||||||
std::unordered_map<uint64_t, int>& uniqueMap);
|
|
||||||
};
|
};
|
||||||
Vector<Material, AT_DNA_COUNT(head.materialCount)> materials;
|
Vector<Material, AT_DNA_COUNT(head.materialCount)> materials;
|
||||||
|
|
||||||
|
|
|
@ -1031,10 +1031,10 @@ zeus::CAABox CAnimData::GetBoundingBox() const
|
||||||
return x108_aabb;
|
return x108_aabb;
|
||||||
|
|
||||||
CAnimTreeEffectiveContribution contrib = x1f8_animRoot->GetContributionOfHighestInfluence();
|
CAnimTreeEffectiveContribution contrib = x1f8_animRoot->GetContributionOfHighestInfluence();
|
||||||
auto search = std::find_if(aabbList.cbegin(), aabbList.cend(),
|
auto search =
|
||||||
[&](const std::pair<std::string, zeus::CAABox>& other) -> bool {
|
rstl::binary_find(aabbList.cbegin(), aabbList.cend(), contrib.x4_name,
|
||||||
return contrib.x4_name == other.first;
|
[](const std::pair<std::string, zeus::CAABox>& other) ->
|
||||||
});
|
const std::string& { return other.first; });
|
||||||
if (search == aabbList.cend())
|
if (search == aabbList.cend())
|
||||||
return x108_aabb;
|
return x108_aabb;
|
||||||
|
|
||||||
|
|
2
hecl
2
hecl
|
@ -1 +1 @@
|
||||||
Subproject commit b094b0638342c12203aa58380b5a99a7a6bebe3a
|
Subproject commit b0fa3912c5cced6d60f0bca7e7c48568038d176c
|
Loading…
Reference in New Issue