mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-08 16:24:55 +00:00
Several GameCube cooking fixes
This commit is contained in:
@@ -22,29 +22,33 @@ void ReadBabeDeadLightToBlender(hecl::blender::PyOutStream& os,
|
||||
return;
|
||||
case BabeDeadLight::LightType::Directional:
|
||||
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.rotation_mode = 'QUATERNION'\n"
|
||||
"lamp_obj.rotation_quaternion = Vector((0,0,-1)).rotation_difference(Vector((%f,%f,%f)))\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.castShadows ? "RAY_SHADOW" : "NOSHADOW");
|
||||
return;
|
||||
case BabeDeadLight::LightType::Custom:
|
||||
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.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;
|
||||
case BabeDeadLight::LightType::Spot:
|
||||
case BabeDeadLight::LightType::Spot2:
|
||||
os.format("lamp = bpy.data.lamps.new('LAMP_%01u_%03u', 'SPOT')\n"
|
||||
"lamp.color = (%f,%f,%f)\n"
|
||||
"lamp.spot_size = %.6g\n"
|
||||
"lamp_obj = bpy.data.objects.new(lamp.name, lamp)\n"
|
||||
"lamp_obj.rotation_mode = 'QUATERNION'\n"
|
||||
"lamp_obj.rotation_quaternion = Vector((0,0,-1)).rotation_difference(Vector((%f,%f,%f)))\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),
|
||||
light.direction.vec[0], light.direction.vec[1], light.direction.vec[2],
|
||||
light.castShadows ? "RAY_SHADOW" : "NOSHADOW");
|
||||
@@ -127,18 +131,18 @@ void WriteBabeDeadLightFromBlender(BabeDeadLight& lightOut, const hecl::blender:
|
||||
lightIn.linear > lightIn.quadratic)
|
||||
{
|
||||
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 &&
|
||||
lightIn.quadratic > lightIn.linear)
|
||||
{
|
||||
lightOut.falloff = BabeDeadLight::Falloff::Quadratic;
|
||||
lightOut.q = 1.f / (lightIn.quadratic / 25000.f);
|
||||
lightOut.q = 25000.f / lightIn.quadratic;
|
||||
}
|
||||
else
|
||||
{
|
||||
lightOut.falloff = BabeDeadLight::Falloff::Constant;
|
||||
lightOut.q = 1.f / (lightIn.constant / 2.f);
|
||||
lightOut.q = 2.f / lightIn.constant;
|
||||
}
|
||||
|
||||
lightOut.color = lightIn.color;
|
||||
|
||||
@@ -1243,8 +1243,6 @@ bool WriteCMDL(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPath
|
||||
hecl::Frontend::Frontend FE;
|
||||
for (const std::vector<Material>& mset : mesh.materialSets)
|
||||
{
|
||||
std::unordered_map<uint64_t, int> uniqueMatMap;
|
||||
|
||||
matSets.emplace_back();
|
||||
MaterialSet& targetMSet = matSets.back();
|
||||
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,
|
||||
mesh.colorLayerCount, mesh.uvLayerCount,
|
||||
false, false, uniqueMatMap);
|
||||
false, false);
|
||||
|
||||
targetMSet.materials.back().binarySize(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();
|
||||
if (surf.verts.size() > 65536)
|
||||
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);
|
||||
if (secSz32 == 0)
|
||||
secSz32 = 32;
|
||||
@@ -1445,7 +1443,7 @@ bool WriteCMDL(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPath
|
||||
SurfaceHeader header;
|
||||
header.centroid = surf.centroid;
|
||||
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.write(writer);
|
||||
|
||||
@@ -1478,8 +1476,6 @@ bool WriteCMDL(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPath
|
||||
WriteDLVal(writer, vaFlags.tex6(), vert.iUv[6]);
|
||||
}
|
||||
|
||||
writer.writeUByte(0);
|
||||
|
||||
writer.fill(atUint8(0), *padIt);
|
||||
++padIt;
|
||||
}
|
||||
@@ -1696,7 +1692,6 @@ bool WriteMREASecs(std::vector<std::vector<uint8_t>>& secsOut, const hecl::Proje
|
||||
MaterialSet matSet;
|
||||
{
|
||||
MaterialPool matPool;
|
||||
std::unordered_map<uint64_t, int> uniqueMatMap;
|
||||
|
||||
size_t surfCount = 0;
|
||||
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,
|
||||
mesh.colorLayerCount, mesh.uvLayerCount,
|
||||
lm, false, uniqueMatMap);
|
||||
lm, false);
|
||||
|
||||
matSet.materials.back().binarySize(endOff);
|
||||
matSet.head.addMaterialEndOff(endOff);
|
||||
@@ -1914,7 +1909,7 @@ bool WriteMREASecs(std::vector<std::vector<uint8_t>>& secsOut, const hecl::Proje
|
||||
SurfaceHeader header;
|
||||
header.centroid = meshXf * zeus::CVector3f(surf.centroid);
|
||||
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.aabbSz = 24;
|
||||
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;
|
||||
header.binarySize(secSz);
|
||||
secSz += 4 + surf.verts.size() * vertSz;
|
||||
secSz += 3 + surf.verts.size() * vertSz;
|
||||
secSz = ROUND_UP_32(secSz);
|
||||
secsOut.emplace_back(secSz, 0);
|
||||
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.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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
uint16_t texel = 0;
|
||||
if (cEntries[e].alpha == 0xff)
|
||||
if (cEntries && cEntries[e].alpha == 0xff)
|
||||
{
|
||||
texel |= 0x8000;
|
||||
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");
|
||||
fclose(inf);
|
||||
png_destroy_read_struct(&pngRead, nullptr, nullptr);
|
||||
png_destroy_read_struct(&pngRead, &info, nullptr);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user