From f78aa159808b4b4d78139e97efa1c3c12dc594f8 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sat, 3 Oct 2015 19:08:24 -1000 Subject: [PATCH] More mesh cooking bug fixes --- hecl/blender/BlenderConnection.cpp | 43 ++++++++++++++-------------- hecl/blender/BlenderConnection.hpp | 20 +++++++------ hecl/blender/hecl/hmdl/HMDLMesh.py | 2 -- hecl/blender/hecl/hmdl/HMDLShader.py | 16 +++++------ hecl/blender/hecl_blendershell.py | 2 +- hecl/lib/ProjectPath.cpp | 2 +- 6 files changed, 43 insertions(+), 42 deletions(-) diff --git a/hecl/blender/BlenderConnection.cpp b/hecl/blender/BlenderConnection.cpp index 63578c327..4c56730d7 100644 --- a/hecl/blender/BlenderConnection.cpp +++ b/hecl/blender/BlenderConnection.cpp @@ -366,26 +366,12 @@ bool BlenderConnection::createBlend(const SystemString& path, BlendType type) if (!strcmp(lineBuf, "FINISHED")) { m_loadedBlend = path; + m_loadedType = type; return true; } return false; } -BlenderConnection::BlendType BlenderConnection::getBlendType() -{ - _writeLine("GETTYPE"); - char lineBuf[256]; - _readLine(lineBuf, sizeof(lineBuf)); - unsigned idx = 0; - while (BlendTypeStrs[idx]) - { - if (!strcmp(BlendTypeStrs[idx], lineBuf)) - return BlendType(idx); - ++idx; - } - return TypeNone; -} - bool BlenderConnection::openBlend(const SystemString& path) { if (m_lock) @@ -403,6 +389,19 @@ bool BlenderConnection::openBlend(const SystemString& path) if (!strcmp(lineBuf, "FINISHED")) { m_loadedBlend = path; + _writeLine("GETTYPE"); + _readLine(lineBuf, sizeof(lineBuf)); + m_loadedType = TypeNone; + unsigned idx = 0; + while (BlendTypeStrs[idx]) + { + if (!strcmp(BlendTypeStrs[idx], lineBuf)) + { + m_loadedType = BlendType(idx); + break; + } + ++idx; + } return true; } return false; @@ -487,12 +486,16 @@ BlenderConnection::DataStream::Mesh::Mesh(BlenderConnection& conn, int skinSlotC norm.emplace_back(conn); conn._readBuf(&colorLayerCount, 4); + if (colorLayerCount > 4) + LogModule.report(LogVisor::FatalError, "mesh has %u color-layers; max 4", colorLayerCount); conn._readBuf(&count, 4); color.reserve(count); for (int i=0 ; i 8) + LogModule.report(LogVisor::FatalError, "mesh has %u UV-layers; max 8", uvLayerCount); conn._readBuf(&count, 4); uv.reserve(count); for (int i=0 ; i& bank, uint32_t sIdx) diff --git a/hecl/blender/BlenderConnection.hpp b/hecl/blender/BlenderConnection.hpp index fc108b9bb..528610412 100644 --- a/hecl/blender/BlenderConnection.hpp +++ b/hecl/blender/BlenderConnection.hpp @@ -28,6 +28,15 @@ extern class BlenderConnection* SharedBlenderConnection; class BlenderConnection { +public: + enum BlendType + { + TypeNone, + TypeMesh, + TypeActor, + TypeArea + }; +private: bool m_lock = false; #if _WIN32 HANDLE m_blenderProc; @@ -36,6 +45,7 @@ class BlenderConnection #endif int m_readpipe[2]; int m_writepipe[2]; + BlendType m_loadedType = TypeNone; SystemString m_loadedBlend; std::string m_startupBlend; size_t _readLine(char* buf, size_t bufSz); @@ -47,16 +57,8 @@ public: BlenderConnection(int verbosityLevel=1); ~BlenderConnection(); - enum BlendType - { - TypeNone, - TypeMesh, - TypeActor, - TypeArea - }; - bool createBlend(const SystemString& path, BlendType type); - BlendType getBlendType(); + BlendType getBlendType() const {return m_loadedType;} bool openBlend(const SystemString& path); bool saveBlend(); void deleteBlend(); diff --git a/hecl/blender/hecl/hmdl/HMDLMesh.py b/hecl/blender/hecl/hmdl/HMDLMesh.py index 9c6f98229..c3ac02733 100644 --- a/hecl/blender/hecl/hmdl/HMDLMesh.py +++ b/hecl/blender/hecl/hmdl/HMDLMesh.py @@ -122,7 +122,6 @@ class VertPool: for ul in range(len(self.ulays)): writebuffunc(struct.pack('I', self.get_uv_idx(loop, ul))) sp = struct.pack('I', self.get_skin_idx(loop.vert)) - print(sp) writebuffunc(sp) def recursive_faces_islands(dlay, list_out, rem_list, skin_slot_set, skin_slot_count, face): @@ -273,7 +272,6 @@ def write_out_surface(writebuffunc, vert_pool, island_faces, mat_idx): # Count estimate writebuffunc(struct.pack('I', len(island_faces) * 3)) - print('EST', len(island_faces) * 3) # Verts themselves last_loop = None diff --git a/hecl/blender/hecl/hmdl/HMDLShader.py b/hecl/blender/hecl/hmdl/HMDLShader.py index 7adc63d71..58217c6ea 100644 --- a/hecl/blender/hecl/hmdl/HMDLShader.py +++ b/hecl/blender/hecl/hmdl/HMDLShader.py @@ -79,14 +79,14 @@ def recursive_color_trace(mat_obj, mesh_obj, tex_list, node, socket=None): soc = soc_from.node.inputs[s+1] if len(soc.links): raise RuntimeError("UV Modifier nodes may not have parameter links (default values only)") - ncomps = len(soc.default_value) - if ncomps > 1: + if soc.type == 'VALUE': + matrix_str += '%g' % soc.default_value + else: + ncomps = len(soc.default_value) matrix_str += 'vec%d(' % ncomps for c in ncomps-1: matrix_str += '%g, ' % soc.default_value[c] matrix_str += '%g)' % soc.default_value[ncomps-1] - else: - matrix_str += '%g' % soc.default_value if s == len(soc_from.node.inputs)-2: matrix_str += ')' @@ -223,14 +223,14 @@ def recursive_alpha_trace(mat_obj, mesh_obj, tex_list, node, socket=None): soc = soc_from.node.inputs[s+1] if len(soc.links): raise RuntimeError("UV Modifier nodes may not have parameter links (default values only)") - ncomps = len(soc.default_value) - if ncomps > 1: + if soc.type == 'VALUE': + matrix_str += '%g' % soc.default_value + else: + ncomps = len(soc.default_value) matrix_str += 'vec%d(' % ncomps for c in ncomps-1: matrix_str += '%g, ' % soc.default_value[c] matrix_str += '%g)' % soc.default_value[ncomps-1] - else: - matrix_str += '%g' % soc.default_value if s == len(soc_from.node.inputs)-2: matrix_str += ')' diff --git a/hecl/blender/hecl_blendershell.py b/hecl/blender/hecl_blendershell.py index ab10528eb..75d4b553f 100644 --- a/hecl/blender/hecl_blendershell.py +++ b/hecl/blender/hecl_blendershell.py @@ -24,7 +24,7 @@ def readpipeline(): retval += ch def writepipeline(linebytes): - print('LINE', linebytes) + #print('LINE', linebytes) os.write(writefd, linebytes + b'\n') def writepipebuf(linebytes): diff --git a/hecl/lib/ProjectPath.cpp b/hecl/lib/ProjectPath.cpp index a15c81e57..96eeb70fc 100644 --- a/hecl/lib/ProjectPath.cpp +++ b/hecl/lib/ProjectPath.cpp @@ -180,7 +180,7 @@ Time ProjectPath::getModtime() const return Time(latestTime); } } - LogModule.report(LogVisor::Error, _S("invalid path type for computing modtime in '%s'"), m_absPath.c_str()); + LogModule.report(LogVisor::FatalError, _S("invalid path type for computing modtime in '%s'"), m_absPath.c_str()); return Time(); }