Blender 3.0 fixes

This commit is contained in:
Phillip Stephens 2022-01-02 19:25:11 -08:00
parent 5491fd75cf
commit 2f0febba27
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
6 changed files with 64 additions and 51 deletions

View File

@ -768,8 +768,8 @@ def make_retro_shader_mp3_color():
input.default_value = (0.0, 0.0, 0.0, 1.0)
input = new_grp.inputs.new("NodeSocketInt", "Add INCA")
input.default_value = 0
input.min_value = 0.000000
input.max_value = 1.000000
input.min_value = 0
input.max_value = 1
input = new_grp.inputs.new("NodeSocketFloatFactor", "OPAC")
input.default_value = 1.0
input.min_value = 0.000000
@ -1057,8 +1057,8 @@ def make_retro_shader_mp3_bloom():
input.max_value = 1.000000
input = new_grp.inputs.new("NodeSocketInt", "Add INCA")
input.default_value = 0
input.min_value = 0.000000
input.max_value = 1.000000
input.min_value = 0
input.max_value = 1
new_grp.outputs.new("NodeSocketShader", "Shader")
nodes = {}
node = new_grp.nodes.new("ShaderNodeMath")
@ -1261,8 +1261,8 @@ def make_retro_shader_mp3():
input.max_value = 1.000000
input = new_grp.inputs.new("NodeSocketInt", "Add INCA")
input.default_value = 0
input.min_value = 0.000000
input.max_value = 1.000000
input.min_value = 0
input.max_value = 1
input = new_grp.inputs.new("NodeSocketFloatFactor", "BNIF")
input.default_value = 0.0
input.min_value = 0.000000

View File

@ -215,17 +215,19 @@ void PAKBridge::addCMDLRigPairs(PAKRouter<PAKBridge>& pakRouter, CharacterAssoci
PAK::Entry* cmdlEnt = (PAK::Entry*)m_pak.lookupEntry(ci.cmdl);
PAK::Entry* cskrEnt = (PAK::Entry*)m_pak.lookupEntry(ci.cskr);
PAK::Entry* cinfEnt = (PAK::Entry*)m_pak.lookupEntry(ci.cinf);
cmdlEnt->name = fmt::format(FMT_STRING("ANCS_{}_{}_model"), id, ci.name);
cskrEnt->name = fmt::format(FMT_STRING("ANCS_{}_{}_skin"), id, ci.name);
cinfEnt->name = fmt::format(FMT_STRING("ANCS_{}_{}_skel"), id, ci.name);
if (ci.cmdlIce.isValid() && ci.cskrIce.isValid()) {
charAssoc.m_cmdlRigs[ci.cmdlIce] = {ci.cskrIce, ci.cinf};
charAssoc.m_cskrToCharacter[ci.cskrIce] =
std::make_pair(entry.id, fmt::format(FMT_STRING("{}.ICE_{}.CSKR"), ci.name, ci.cskrIce));
PAK::Entry* cmdlEnt = (PAK::Entry*)m_pak.lookupEntry(ci.cmdlIce);
PAK::Entry* cskrEnt = (PAK::Entry*)m_pak.lookupEntry(ci.cskrIce);
cmdlEnt->name = fmt::format(FMT_STRING("ANCS_{}_{}_icemodel"), id, ci.name);
cskrEnt->name = fmt::format(FMT_STRING("ANCS_{}_{}_iceskin"), id, ci.name);
if (cmdlEnt != nullptr && cskrEnt != nullptr && cinfEnt != nullptr) {
cmdlEnt->name = fmt::format(FMT_STRING("ANCS_{}_{}_model"), id, ci.name);
cskrEnt->name = fmt::format(FMT_STRING("ANCS_{}_{}_skin"), id, ci.name);
cinfEnt->name = fmt::format(FMT_STRING("ANCS_{}_{}_skel"), id, ci.name);
if (ci.cmdlIce.isValid() && ci.cskrIce.isValid()) {
charAssoc.m_cmdlRigs[ci.cmdlIce] = {ci.cskrIce, ci.cinf};
charAssoc.m_cskrToCharacter[ci.cskrIce] =
std::make_pair(entry.id, fmt::format(FMT_STRING("{}.ICE_{}.CSKR"), ci.name, ci.cskrIce));
PAK::Entry* cmdlEnt = (PAK::Entry*)m_pak.lookupEntry(ci.cmdlIce);
PAK::Entry* cskrEnt = (PAK::Entry*)m_pak.lookupEntry(ci.cskrIce);
cmdlEnt->name = fmt::format(FMT_STRING("ANCS_{}_{}_icemodel"), id, ci.name);
cskrEnt->name = fmt::format(FMT_STRING("ANCS_{}_{}_iceskin"), id, ci.name);
}
}
}
std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>> animInfo;

View File

@ -338,7 +338,7 @@ bool FRME::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
"cam.lens_unit = 'FOV'\n"
"cam.clip_start = {}\n"
"cam.clip_end = {}\n"
"bpy.context.scene.render.resolution_x = 480 * {}\n"),
"bpy.context.scene.render.resolution_x = int(480 * {})\n"),
proj->znear, proj->zfar, proj->aspect);
if (proj->aspect > 1.f)
os.format(FMT_STRING("cam.angle = math.atan2({}, 1.0 / math.tan(math.radians({} / 2.0))) * 2.0\n"),

View File

@ -505,7 +505,11 @@ try:
bpy.context.preferences.filepaths.save_version = 0
print('SAVING %s' % loaded_blend)
if loaded_blend:
if 'FINISHED' in bpy.ops.wm.save_as_mainfile(filepath=loaded_blend, check_existing=False, compress=True):
if bpy.app.version >= (3, 0, 0):
ret = bpy.ops.wm.save_as_mainfile(filepath=loaded_blend, check_existing=False, compress=False)
else:
ret = bpy.ops.wm.save_as_mainfile(filepath=loaded_blend, check_existing=False, compress=True)
if 'FINISHED' in ret:
writepipestr(b'FINISHED')
else:
writepipestr(b'CANCELLED')

View File

@ -79,44 +79,51 @@ SDNARead::SDNARead(std::string_view path) {
r.readUBytesToBuf(magicBuf, 7);
r.seek(0, athena::SeekOrigin::Begin);
if (strncmp(magicBuf, "BLENDER", 7)) {
/* Try gzip decompression */
std::unique_ptr<uint8_t[]> compBuf(new uint8_t[4096]);
m_data.resize((length * 2 + 4095) & ~4095);
z_stream zstrm = {};
inflateInit2(&zstrm, 16 + MAX_WBITS);
zstrm.next_out = (Bytef*)m_data.data();
zstrm.avail_out = m_data.size();
zstrm.total_out = 0;
atUint32 magic = hecl::SLittle(*(atUint32*)(magicBuf));
if (magic == 0xfd2fb528) {
/* Try zstandard decompression */
// TODO: Implement
m_data = {};
} else if (magic == 0x88b1f) {
/* Try gzip decompression */
std::unique_ptr<uint8_t[]> compBuf(new uint8_t[4096]);
m_data.resize((length * 2 + 4095) & ~4095);
z_stream zstrm = {};
inflateInit2(&zstrm, 16 + MAX_WBITS);
zstrm.next_out = (Bytef*)m_data.data();
zstrm.avail_out = m_data.size();
zstrm.total_out = 0;
atUint64 rs;
while ((rs = r.readUBytesToBuf(compBuf.get(), 4096))) {
int inflateRet;
zstrm.next_in = compBuf.get();
zstrm.avail_in = rs;
while (zstrm.avail_in) {
if (!zstrm.avail_out) {
zstrm.avail_out = m_data.size();
m_data.resize(zstrm.avail_out * 2);
zstrm.next_out = (Bytef*)m_data.data() + zstrm.avail_out;
atUint64 rs;
while ((rs = r.readUBytesToBuf(compBuf.get(), 4096))) {
int inflateRet;
zstrm.next_in = compBuf.get();
zstrm.avail_in = rs;
while (zstrm.avail_in) {
if (!zstrm.avail_out) {
zstrm.avail_out = m_data.size();
m_data.resize(zstrm.avail_out * 2);
zstrm.next_out = (Bytef*)m_data.data() + zstrm.avail_out;
}
inflateRet = inflate(&zstrm, Z_NO_FLUSH);
if (inflateRet == Z_STREAM_END)
break;
if (inflateRet != Z_OK) {
inflateEnd(&zstrm);
m_data = std::vector<uint8_t>();
return;
}
}
inflateRet = inflate(&zstrm, Z_NO_FLUSH);
if (inflateRet == Z_STREAM_END)
break;
if (inflateRet != Z_OK) {
inflateEnd(&zstrm);
m_data = std::vector<uint8_t>();
return;
}
}
if (inflateRet == Z_STREAM_END)
break;
}
inflateEnd(&zstrm);
inflateEnd(&zstrm);
if (strncmp((char*)m_data.data(), "BLENDER", 7)) {
m_data = std::vector<uint8_t>();
return;
if (strncmp((char*)m_data.data(), "BLENDER", 7)) {
m_data = std::vector<uint8_t>();
return;
}
}
} else {
m_data.resize(length);

View File

@ -161,7 +161,7 @@ bool IsPathBlend(const hecl::ProjectPath& path) {
}
buf = hecl::SLittle(buf);
return buf == 0x4e454c42 || buf == 0x88b1f;
return buf == 0x4e454c42 || buf == 0x88b1f || buf == 0xfd2fb528;
}
bool IsPathYAML(const hecl::ProjectPath& path) {