mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-08 17:04:55 +00:00
HECL Compiler bug fixes
This commit is contained in:
@@ -558,21 +558,25 @@ BlenderConnection::DataStream::Mesh::Mesh(BlenderConnection& conn, int skinSlotC
|
||||
BlenderConnection::DataStream::Mesh::Material::Material
|
||||
(BlenderConnection& conn)
|
||||
{
|
||||
char buf[4096];
|
||||
conn._readLine(buf, 4096);
|
||||
source.assign(buf);
|
||||
uint32_t bufSz;
|
||||
conn._readBuf(&bufSz, 4);
|
||||
name.assign(bufSz, ' ');
|
||||
conn._readBuf(&name[0], bufSz);
|
||||
|
||||
conn._readBuf(&bufSz, 4);
|
||||
source.assign(bufSz, ' ');
|
||||
conn._readBuf(&source[0], bufSz);
|
||||
|
||||
uint32_t texCount;
|
||||
conn._readBuf(&texCount, 4);
|
||||
texs.reserve(texCount);
|
||||
for (uint32_t i=0 ; i<texCount ; ++i)
|
||||
{
|
||||
conn._readLine(buf, 4096);
|
||||
#if HECL_UCS2
|
||||
SystemString absolute = HECL::UTF8ToWide(buf);
|
||||
#else
|
||||
SystemString absolute(buf);
|
||||
#endif
|
||||
conn._readBuf(&bufSz, 4);
|
||||
std::string readStr(bufSz, ' ');
|
||||
conn._readBuf(&readStr[0], bufSz);
|
||||
SystemStringView absolute(readStr);
|
||||
|
||||
SystemString relative =
|
||||
conn.m_loadedBlend.getProject().getProjectRootPath().getProjectRelativeFromAbsolute(absolute);
|
||||
texs.emplace_back(conn.m_loadedBlend.getProject().getProjectWorkingPath(), relative);
|
||||
|
||||
@@ -308,6 +308,7 @@ public:
|
||||
/* HECL source of each material */
|
||||
struct Material
|
||||
{
|
||||
std::string name;
|
||||
std::string source;
|
||||
std::vector<ProjectPath> texs;
|
||||
|
||||
|
||||
@@ -354,7 +354,7 @@ def shader(mat_obj, mesh_obj):
|
||||
tex_paths = [get_texture_path(name) for name in tex_list]
|
||||
|
||||
if mat_obj.game_settings.alpha_blend == 'ALPHA' or mat_obj.game_settings.alpha_blend == 'ALPHA_SORT':
|
||||
return "HECLBlend(%s, %s)" % (color_trace_result, alpha_trace_result), tex_paths
|
||||
return "HECLAlpha(%s, %s)" % (color_trace_result, alpha_trace_result), tex_paths
|
||||
elif mat_obj.game_settings.alpha_blend == 'ADD':
|
||||
return "HECLAdditive(%s, %s)" % (color_trace_result, alpha_trace_result), tex_paths
|
||||
else:
|
||||
|
||||
@@ -95,11 +95,10 @@ def cook(writebuf, mesh_obj, max_skin_banks, max_octant_length=None):
|
||||
rna_loops = copy_mesh.loops
|
||||
|
||||
# Filter out useless AABB points and send data
|
||||
aabb = bytearray()
|
||||
for comp in copy_obj.bound_box[0]:
|
||||
writebuf(struct.pack('f', comp))
|
||||
for comp in copy_obj.bound_box[6]:
|
||||
writebuf(struct.pack('f', comp))
|
||||
pt = copy_obj.bound_box[0]
|
||||
writebuf(struct.pack('fff', pt[0], pt[1], pt[2]))
|
||||
pt = copy_obj.bound_box[6]
|
||||
writebuf(struct.pack('fff', pt[0], pt[1], pt[2]))
|
||||
|
||||
# Create master BMesh and VertPool
|
||||
bm_master = bmesh.new()
|
||||
@@ -128,10 +127,14 @@ def cook(writebuf, mesh_obj, max_skin_banks, max_octant_length=None):
|
||||
for mat in bpy.data.materials:
|
||||
if mat.name.endswith('_%u_%u' % (grp_idx, mat_idx)):
|
||||
hecl_str, texs = HMDLShader.shader(mat, mesh_obj)
|
||||
writebuf((hecl_str + '\n').encode())
|
||||
writebuf(struct.pack('I', len(mat.name)))
|
||||
writebuf(mat.name.encode())
|
||||
writebuf(struct.pack('I', len(hecl_str)))
|
||||
writebuf(hecl_str.encode())
|
||||
writebuf(struct.pack('I', len(texs)))
|
||||
for tex in texs:
|
||||
writebuf((tex + '\n').encode())
|
||||
writebuf(struct.pack('I', len(tex)))
|
||||
writebuf(tex.encode())
|
||||
found = True
|
||||
break
|
||||
if not found:
|
||||
@@ -141,10 +144,14 @@ def cook(writebuf, mesh_obj, max_skin_banks, max_octant_length=None):
|
||||
for mat_idx in sorted_material_idxs:
|
||||
mat = mesh_obj.data.materials[mat_idx]
|
||||
hecl_str, texs = HMDLShader.shader(mat, mesh_obj)
|
||||
writebuf((hecl_str + '\n').encode())
|
||||
writebuf(struct.pack('I', len(mat.name)))
|
||||
writebuf(mat.name.encode())
|
||||
writebuf(struct.pack('I', len(hecl_str)))
|
||||
writebuf(hecl_str.encode())
|
||||
writebuf(struct.pack('I', len(texs)))
|
||||
for tex in texs:
|
||||
writebuf((tex + '\n').encode())
|
||||
writebuf(struct.pack('I', len(tex)))
|
||||
writebuf(tex.encode())
|
||||
|
||||
# Output vert pool
|
||||
vert_pool.write_out(writebuf, mesh_obj.vertex_groups)
|
||||
|
||||
Reference in New Issue
Block a user